如何在Visual Studio 2008 C ++中链接.lib [英] How to link a .lib in Visual Studio 2008 C++

查看:105
本文介绍了如何在Visual Studio 2008 C ++中链接.lib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现将.lib文件正确链接到我的C ++ Win32控制台应用程序确实很困难.这是我的问题.

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

就像在这篇MSDN文章中一样,我已经开发了MathFuncsLib.lib文件.

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

然后,在MyExecRefsLib Win32控制台应用程序中,我想链接到上述文件.因此,在MyExecRefsLib文件夹(.sln文件所在的文件夹)内,我创建了一个名为"LibraryFiles"的目录,并放置了MathFuncsLib.lib文件和MathFuncsLib.h文件.

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.

然后,在属性"->链接器"->输入"中,添加"MathFuncsLib.lib"和"MathFuncsLib.h"(无完整路径),然后在属性"->链接器"->其他库目录"中,将路径添加至我的文件夹"LibraryFiles",这是网络上关于此问题的几乎所有线程都告诉我要做的事情.

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:

严重错误C1083:无法打开 包含文件. 'MathFuncsLib.h':否 这样的文件或目录.

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

我做错了什么?请帮忙. 请注意,我的代码与上述MSDN链接中的代码完全相同.

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

推荐答案

要链接.lib文件,您只需:

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

  • 在项目名称上右击,选择属性"
  • 在属性"->配置属性"->"C/C ++"->常规"其他包含目录"下,将路径添加到您的.h文件中
  • 在属性"->链接器"->输入"下,添加.lib文件的路径和名称

就是这样.

这篇关于如何在Visual Studio 2008 C ++中链接.lib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆