Share via


Visual Studio doesn't generate a lib file.

Question

Friday, June 5, 2009 3:35 PM

Hi, I am trying to build a simple Visual C++ 2003 project on Windows XP Professional, but I am stuck in a silly error: Visual Studio doesn't build the lib file that comes with dll.

I've used Visual C++ 2008 Express for sometime now and whenever I needed to build a dll I just went to the project properties and changed the Configuration Type. Then when I built the project, both the dll and lib files would get generated.

I have done the same with Visual Studio 200,3 but for some reason the lib file doesn't get generated. I've tried building the solution on both Debug and Release modes but the result is the same.

Also I've checked the Import Library option on Project Properties -> Linker -> Advanced tab and it says "$(OutDir)/Verifier320Helper.lib" to both Release and Debug configurations.

What I am doing wrong here? Can anyone help me?

PS: I really need to genearate the lib file, because I need to import this dll in another project, and to do this I need the lib file.

Thanks,
Komyg

All replies (2)

Friday, June 5, 2009 5:17 PM âś…Answered | 2 votes

Are your types are declared to export correctly [using __declspec(dllexport)] when you're building the DLL?  If you leave this step out, VC++ 2003 would not generate a lib file.

Reed Copsey, Jr. - http://reedcopsey.com


Friday, June 5, 2009 5:35 PM

Yes, that was the problem, I had forgot to add the __declspec(dllexport) directive. When I added this directive, the lib file was generated as expected.

Thus my code ended up like this:

#define EXPORT __declspec (dllexport)

extern "C" EXPORT int initialize();

Thanks,
Komyg