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:
Created a empty project in VC++,
Added a .c file,
Added few c functions,
Created a .h file for the same,
Changed the projects type to .lib
Built the project.
No problem till here.
Now,
I copied the .h and the .lib file to desktop,
created another VC++ empty project of type .exe,
In poject prop.->config. prop.->c/开发者_StackOverflow社区c++->additional include directories,I added the path to desktop,
In poject prop.->config. prop.->linker->additional library dependencies,I added the path to desktop,
building the project gives
LNK2019 (unresolved external symbol _...)
andfatal 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.
精彩评论