views:

26

answers:

3

I'm using Visual Studio 2008 under Windows 7. I have a .lib and accompanying .h files (which make use of wxWidgets if that makes a difference) which compile without any issues.

I'm trying to import that library into a GUI project but when I do, the main class I'm interested in doesn't appear to be there?

I've added #include "MyLib.h" to the gui and added mylib.lib to the including libraries but for some reason I get:

MyLib.obj : error LNK2001: unresolved external symbol "public: __thiscall MyLibClass::MyLibClass(void)" (??0MyLibClass@@QAE@XZ)

Why might that happen?

+1  A: 

Maybe are you referencing an old version of the library? Are you sure the linked libraries in the project settings are set to the right path?

onof
Got it - I'd changed the output directory a while ago and was using the wrong one.
Jon Cage
A: 

It sounds like when you built the library, you didn't include all the object files. Note, in particular, that it's mylib.obj that's showing the unresolved external. It seems fair to guess that mylib.obj is in mylib.lib, in which case it's saying that mylib.lib doesn't include all the "stuff" it depends upon.

Jerry Coffin
+1  A: 

Make sure you do a rebuild of MyLib.lib and then add it to the second project by adding:

#pragma comment (lib,"C:\full\path\to\lib\here.lib")

to any source file.

If it works, then you know you have a problem with your paths

monoceres