How to link a .lib in Visual Studio 2008 C++

北慕城南 提交于 2020-01-23 02:45:08

问题


I'm finding it really difficult to properly link a .lib file to my C++ Win32 Console Application. Here's my problem.

Just as in this MSDN article, I have developed a MathFuncsLib.lib file.

http://msdn.microsoft.com/en-us/library/ms235627%28v=vs.80%29.aspx

Then, in the MyExecRefsLib Win32 Console App, I want to link to the above file. So, inside MyExecRefsLib folder (same folder where .sln file resides) I created a directory called "LibraryFiles" and placed both MathFuncsLib.lib file AND MathFuncsLib.h file.

Then, in Properties->Linker->Input I added both "MathFuncsLib.lib" and "MathFuncsLib.h" (without full path) and then in Properties->Linker->Additional Library Directories I added the path to my folder "LibraryFiles" which is what pretty much EVERY thread on the web about this problem tells me to do.

But now it gives me the following error:

fatal error C1083: Cannot open the include file. 'MathFuncsLib.h': No such file or directory.

What am I doing wrong? Please help. Note that my code is exactly the same as what's in the above given MSDN link.


回答1:


To link with a .lib file, you just need to:

  • right clic on the project name, select Properties
  • under Properties->configuration properties->C/C++->General item "other include directories" add the path to your .h file
  • under Properties->Linker->Input add the path and name of your .lib file

And that's it.



来源:https://stackoverflow.com/questions/6093325/how-to-link-a-lib-in-visual-studio-2008-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!