Je suis nouveau à C++ et ecplice et ils donnent définitivement à mon un temps difficile :)
Je suis tring pour écrire une application simple qui comprend le projet principal avec des références à d'autres projets
i écrit le fichier suivant dans le projet commun:eclipse C + + ajouter une référence non définie référence à l'erreur de méthode
#ifndef MANAGEDLOG_H_
#define MANAGEDLOG_H_
#include string
#include iostream
#include fstream
using namespace std;
class ManagedLog
{
ofstream _fileStream;
public :
ManagedLog::ManagedLog(string path);
ManagedLog::~ManagedLog();
void ManagedLog::WriteInfoLog(string message,string stackTrace);
};
#endif /* MANAGEDLOG_H_ */
/*
* ManagedLog.cpp
*
* Created on: 18/06/2010
* Author: Eran
*/
#include "ManagedLog.h"
#include iostream
#include fstream
ManagedLog::ManagedLog(string path)
{
_path=path;
}
ManagedLog::~ManagedLog()
{
}
void ManagedLog:: WriteInfoLog(string message,string stackTrace)
{
ofstream myfile;
myfile.open("Eample.txt",ios::app);
myfile.close();
}
et l'exécuter dans un langage simple projet mondial hellow:
#include "ManagedLog.h"
#include
using namespace std;
int main() {
ManagedLog * log = new ManagedLog("path");
log->WriteInfoLog("test","RunLog/Main");
cout
but I'm getting this error:
*** Build of configuration Debug for project RunLog ****
**** Internal Builder is used for build ****
g++ -ID:\EclipseWorkSpace\LogManager -O0 -g3 -Wall -c -fmessage-length=0 -osrc\RunLog.o ..\src\RunLog.cpp
g++ -LD:\EclipseWorkSpace\LogManager\Release -oRunLog.exe src\RunLog.o
src\RunLog.o: In function `main':
D:/EclipseWorkSpace/RunLog/Debug/../src/RunLog.cpp:13: undefined reference to `ManagedLog::ManagedLog(std::string)'
D:/EclipseWorkSpace/RunLog/Debug/../src/RunLog.cpp:14: undefined reference to `ManagedLog::WriteInfoLog(std::string, std::string)'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 574 ms.
I added #include "ManagedLog.cpp" and the code work just fine but i guess this is not the right way to do it i read a lot about it but found no answer that i can impliment since i don't understad the term is the reanswers can anybody please help me with the right way to point to other project or dll in this environment?
thanks
Eran
comment puis-je lier les fichiers .o au .exe? – Eran
@Eran, je n'ai aucune idée - je n'ai jamais utilisé éclipse. Vous voulez une ligne de commande qui ressemble à 'g ++ src \ RunLog.o src \ ManagedLog.o -o RunLog.exe'. –
OK !! J'ai recherché partout dans les propriétés de LinkLog pour la propriété de linker et l'ai trouvée dans C/C++ Build-> Setting-> ToolSettings -> MinGW C++ Linker, j'ouvre le dossier de Libararies et ai trouvé un endroit pour ajouter l'objet, j'ai ajouté le dossier ManagedLog.o et cela a fonctionné comme une magie Merci beaucoup pour votre conseil, je voulais juste quitter C# (-: – Eran