开发者

Issue in using a .lib in a VS2008/VC project

I wanted to learn how to use a .lib file in my C application.

So, I followed these steps:

  1. Created a empty project in VC++,

  2. Added a .c file,

  3. Added few c functions,

  4. Created a .h file for the same,

  5. Changed the projects type to .lib

  6. Built the project.

No problem till here.

Now,

  1. I copied the .h and the .lib file to desktop,

  2. created another VC++ empty project of type .exe,

  3. In poject prop.->config. prop.->c/开发者_StackOverflow社区c++->additional include directories,I added the path to desktop,

  4. In poject prop.->config. prop.->linker->additional library dependencies,I added the path to desktop,

  5. building the project gives LNK2019 (unresolved external symbol _...) and fatal error LNK1120 (unresolved external symbols).

What am I doing wrong? Also what would be the steps to use a .dll instead of .lib?

Configuration: Windows 7, VS2008.


You also have to add the library by name to the list of Additional Dependencies in Linker->Input options for your Project.

Do you really want this linked in from the desktop, by the way? Typically some project-relative path or environment variable would be the way to do this - you do not want to link from desktop on a build server, for example.

Switching to a DLL will not help because you still need to use the export library (.LIB) file for your DLL to satisfy the link-time dependencies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜