Tell linker to add cpp files
-
Hey guys, I got a linker problem.. I have written some .h files and .cpp files for being used in any project, and put them to a folder named "common". :) Now I have a project and I set up the vc directories. I add include and source file folders to there. And I include the main .h header file. Compiling is ok :) but when it comes to linking linker says unresolved external symbol :doh: ... So it couldn't find the body in the cpp file. So how can I tell the linker to use the cpp file? :confused: Thank you... :-D
-
Hey guys, I got a linker problem.. I have written some .h files and .cpp files for being used in any project, and put them to a folder named "common". :) Now I have a project and I set up the vc directories. I add include and source file folders to there. And I include the main .h header file. Compiling is ok :) but when it comes to linking linker says unresolved external symbol :doh: ... So it couldn't find the body in the cpp file. So how can I tell the linker to use the cpp file? :confused: Thank you... :-D
You don't tell the linker to use the cpp file - the cpp file's source code, but the linker wants object code... What you need to do is give the linker a command line that tells it all the object files that are produced by the compiler, plus any import libraries for system libraries (DLLs) that you reference. BTW - just suggesting here, but we might be able to help even more if you gave an exact error message.
-
Hey guys, I got a linker problem.. I have written some .h files and .cpp files for being used in any project, and put them to a folder named "common". :) Now I have a project and I set up the vc directories. I add include and source file folders to there. And I include the main .h header file. Compiling is ok :) but when it comes to linking linker says unresolved external symbol :doh: ... So it couldn't find the body in the cpp file. So how can I tell the linker to use the cpp file? :confused: Thank you... :-D
You need to add your cpp files to your project otherwise it won't know where it should look for the actual implementations of the methods and rest declared in the header files.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <
-
You don't tell the linker to use the cpp file - the cpp file's source code, but the linker wants object code... What you need to do is give the linker a command line that tells it all the object files that are produced by the compiler, plus any import libraries for system libraries (DLLs) that you reference. BTW - just suggesting here, but we might be able to help even more if you gave an exact error message.
Error 1 error LNK2019: unresolved external symbol "public: __thiscall CXControl::~CXControl(void)" (??1CXControl@@QAE@XZ) referenced in function "public: __thiscall CXDesktop::~CXDesktop(void)" (??1CXDesktop@@QAE@XZ) DX.obj This is one of the errors... SO how can I tell Linker/Compiler to do that :confused:
-
You need to add your cpp files to your project otherwise it won't know where it should look for the actual implementations of the methods and rest declared in the header files.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <
-
Actually this is exacly I am trying to avoid... I do not want to add .cpp files. But if I have to then I will.. So any other suggestions?
Well, you could build libraries of your implementations and link to these using #import or such. I never did this so i don't know how it works but i believe that is one way of doing it.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <
-
Error 1 error LNK2019: unresolved external symbol "public: __thiscall CXControl::~CXControl(void)" (??1CXControl@@QAE@XZ) referenced in function "public: __thiscall CXDesktop::~CXDesktop(void)" (??1CXDesktop@@QAE@XZ) DX.obj This is one of the errors... SO how can I tell Linker/Compiler to do that :confused:
I should have read your original message more closely - anyway - what Code-o-mat said, add the cpp files to your VC++ project. It'll compile them and link their object files into the final executable.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
Actually this is exacly I am trying to avoid... I do not want to add .cpp files. But if I have to then I will.. So any other suggestions?
Create a separate static library project for the CPP files and get that to build a static library from the cpp files for you. Then, tell the project that uses that functionality to link against the static library.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
Create a separate static library project for the CPP files and get that to build a static library from the cpp files for you. Then, tell the project that uses that functionality to link against the static library.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p