I'm writing an application which uses libraries written by someone else. They include a bunch of examples with their code, which all compile fine with no errors. However, when I simply copy paste (with permission of course) one of these examples into a new project to use as a template, I cant make it compile.
I've changed the path in Properties -> VC++ Directories -> Include Directories to the one which contains all the libraries, so I should have access to all the same stuff as the one which compiles properly.
For example (I've cut a lot out to try to illustrate the problem a little better)
#include <vhandtk/vhtBase.h>
int main(){
vhtTrackerEmulator *tracker; //This causes no problems
tracker = new vhtTrackerEmulator(); //This causes a fatal error
return 0;
}
The above code compiles with no errors in the demos, but I copy pasted it into a new project, and it fails with the following error:
error LNK2019: unresolved external symbol "public: __thiscall vhtTrackerEmulator::vhtTrackerEmulator(void) (??0vhtTrackerEmulator@@QAE@XZ) referenced in function _main
I'm using Visual C++ 2010 Express on Windows XP service pack 3.
Sorry if question is unclear or poorly phrased, many thanks for your help.
Best regards
Dave
I'm afraid both these suggestions fail with the same error message as before. I'm fairly sure it isn't an error in the written code, since the exact same lines of code compile and run with no errors in another (example) project written by someone else.
Could it be some setting or property or option I've neglected to use? Something to do with the compiler or linker?
Then my next guess is that you are not linking to the correct import library. Double check the what libraries you're linking to in the working project compared to the not working one. Or check the documentation on for the library.
Is there a good way to compare which libraries both projects link to? I'm quite new to programming and Visual C++, so sorry if this takes a little longer than it should.
What I'm looking for is any difference in the way that the two projects are compiled, or any differences in their properties which might explain why one works and the other doesn't.
I'm fairly certain that I've linked to the same libraries the working project does. I'm afraid there isn't really any documentation for the libraries.
Sorry if I'm missing something obvious.
Thanks for your help
I figured out what it was. There were a few .lib files which were needed, but I didnt realise I had to add them individually in Linker->Input->Additional Dependencies, as well as add the library directory in Linker->General->Addtional Library Directories. So with hindsight it was fairly obvious after all, sorry!
Many thanks for the help.