Link error
-
I have a class on a library on the file Libr.h/.cpp I build a doc/view app. I link the header in Doc.h using
#include "Libr.h"
, and the code is pasted in Doc.cpp using#include "Libr.cpp"
. View knows that the library exist because in View.h I have#include "Doc.h"
. So I have some code that use the library in Doc.pp and View.cpp. But the problem is: Doc.cpp OK View.cpp: Link error LNK2019 (functions not finded when link: but no problems when compile) So I tried to past#include "Libr.cpp"
in View.cpp, and then: Doc.cpp: Link error LNK2019 View.cpp OK Damn! And this appens only with some functions of the library, and strange thing is that this functions are very very similar to other functions that haven't got any problem!! Can anybody help me?? (sorry for the long message)Have a nice code day ;)
-
I have a class on a library on the file Libr.h/.cpp I build a doc/view app. I link the header in Doc.h using
#include "Libr.h"
, and the code is pasted in Doc.cpp using#include "Libr.cpp"
. View knows that the library exist because in View.h I have#include "Doc.h"
. So I have some code that use the library in Doc.pp and View.cpp. But the problem is: Doc.cpp OK View.cpp: Link error LNK2019 (functions not finded when link: but no problems when compile) So I tried to past#include "Libr.cpp"
in View.cpp, and then: Doc.cpp: Link error LNK2019 View.cpp OK Damn! And this appens only with some functions of the library, and strange thing is that this functions are very very similar to other functions that haven't got any problem!! Can anybody help me?? (sorry for the long message)Have a nice code day ;)
-
I have a class on a library on the file Libr.h/.cpp I build a doc/view app. I link the header in Doc.h using
#include "Libr.h"
, and the code is pasted in Doc.cpp using#include "Libr.cpp"
. View knows that the library exist because in View.h I have#include "Doc.h"
. So I have some code that use the library in Doc.pp and View.cpp. But the problem is: Doc.cpp OK View.cpp: Link error LNK2019 (functions not finded when link: but no problems when compile) So I tried to past#include "Libr.cpp"
in View.cpp, and then: Doc.cpp: Link error LNK2019 View.cpp OK Damn! And this appens only with some functions of the library, and strange thing is that this functions are very very similar to other functions that haven't got any problem!! Can anybody help me?? (sorry for the long message)Have a nice code day ;)
you need to add the lib file to the link tab in the project settings.
-Prakash
-
#include "Libr.cpp" is wrong. Include Libr.h in your Doc.h & include Doc.h in your Doc.cpp
tuxyboy wrote:
#include "Libr.cpp" is wrong.
is actually not wrong but poor way of programming.
-Prakash
-
you need to add the lib file to the link tab in the project settings.
-Prakash
Sorry, but I prefere the simple:sigh: use of
#include
. I have good news: In libr.h/.cpp there was a lot ofinline
functions, well... I modify the files cutting that word and now everything is running. But I want to use inline: I need it!! So, do you know if it is possible that the linker doesn't like the keywordinline
or if the use of 'inline' could give this error?? ThaksHave a nice code day ;)
-
Sorry, but I prefere the simple:sigh: use of
#include
. I have good news: In libr.h/.cpp there was a lot ofinline
functions, well... I modify the files cutting that word and now everything is running. But I want to use inline: I need it!! So, do you know if it is possible that the linker doesn't like the keywordinline
or if the use of 'inline' could give this error?? ThaksHave a nice code day ;)
_Russell_ wrote:
Sorry, but I prefere the simple use of #include.
linking the library to your project is also a simple way of doing.
-Prakash
-
Sorry, but I prefere the simple:sigh: use of
#include
. I have good news: In libr.h/.cpp there was a lot ofinline
functions, well... I modify the files cutting that word and now everything is running. But I want to use inline: I need it!! So, do you know if it is possible that the linker doesn't like the keywordinline
or if the use of 'inline' could give this error?? ThaksHave a nice code day ;)
btw, is the doc-view app a MFC project?
-Prakash
-
btw, is the doc-view app a MFC project?
-Prakash
-
Add the .cpp file to the project and
#include
the .h file whereever you need. It should compile and link properly.
-Prakash
-
I have a class on a library on the file Libr.h/.cpp I build a doc/view app. I link the header in Doc.h using
#include "Libr.h"
, and the code is pasted in Doc.cpp using#include "Libr.cpp"
. View knows that the library exist because in View.h I have#include "Doc.h"
. So I have some code that use the library in Doc.pp and View.cpp. But the problem is: Doc.cpp OK View.cpp: Link error LNK2019 (functions not finded when link: but no problems when compile) So I tried to past#include "Libr.cpp"
in View.cpp, and then: Doc.cpp: Link error LNK2019 View.cpp OK Damn! And this appens only with some functions of the library, and strange thing is that this functions are very very similar to other functions that haven't got any problem!! Can anybody help me?? (sorry for the long message)Have a nice code day ;)
Hi, I had the same link error. I feel the problem is inclusion of your header files(#include "Libr.h") in side the Doc.h. Try to include the header files inside the .cpp files, not inside the .h files. If you want exactly inside the .h file, then include inside of #define. otherwise system will produce runtime error because of multiple inclution. in your case you included "#include "Libr.h" inside your doc.h and doc.h is included inside view.h and etc.. try to avoid this and "#include "Libr.h" should be inside your doc.cpp Dont include .cpp file. .h file will take care everythings of .cpp best of luck,, regards Vallikumar A