# Tutorial :Problems importing a .lib into another project

### Question:

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?

### Solution:1

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?

### Solution:2

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

### Solution:3

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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »