将库添加到 Visual Studio 2008 C++ 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1114914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add Library to Visual Studio 2008 C++ Project
提问by Chance
I'm completely new to Visual Studio and I'm having some trouble getting a project started with Visual Studio 2008. I'm experimenting with MAPI, and I'm getting error messages like this when I go to build the project:
我是 Visual Studio 的新手,在使用 Visual Studio 2008 启动项目时遇到了一些麻烦。我正在试验 MAPI,在我开始构建项目时收到如下错误消息:
"unresolved external symbol _MAPIUninitialize@0 referenced in function _main"
“在函数 _main 中引用了未解析的外部符号 _MAPIUninitialize@0”
I know I need to link to MAPI32.lib, but the guides I have found thus far have indicated going to the "Visual Studio settings linktab" and adding it there (which was - apparently - from an older version of Visual Studio). I can't find anything like that in the project properties linker or C/C++ sections of VS 2008.
我知道我需要链接到 MAPI32.lib,但到目前为止我找到的指南已经指出转到“Visual Studio 设置链接选项卡”并将其添加到那里(显然是来自旧版本的 Visual Studio)。我在 VS 2008 的项目属性链接器或 C/C++ 部分中找不到类似的东西。
Where do I need to tell Visual Studio to use that library?
我需要在哪里告诉 Visual Studio 使用该库?
Thanks
谢谢
回答by RichieHindle
It's under Project Properties / Configuration Properties / Linker / Input / Additional Dependencies.
它位于项目属性/配置属性/链接器/输入/附加依赖项下。
The help tip at the bottom of the screen says "Specifies additional items add to the line line (ex: kernel32.lib)".
屏幕底部的帮助提示说“指定添加到行行的其他项目(例如:kernel32.lib)”。
回答by Paul
Project Properties->Linker->Input->Additional Dependencies
项目属性->链接器->输入->附加依赖项
You can also use
#pragma comment( lib, "mapi32" )
in one of your source files. As noted MSDN here is a similar library addition using the pragma technique MSDN - Creating a Basic Winsock Application
您还可以#pragma comment( lib, "mapi32" )
在源文件之一中使用
。正如 MSDN 所指出的,这里是使用 pragma 技术MSDN - 创建一个基本的 Winsock 应用程序的一个类似的库添加
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
#pragma comment(lib, "Ws2_32.lib")
int main() {
return 0;
}
回答by mabeiyi
Three simple steps:
三个简单的步骤:
- Project Properties->Linker->General->Additional Library Directories choose the folder which contains your .lib file
- Project Properties->Linker->General->Additional Library Directories 选择包含 .lib 文件的文件夹
2.Project Properties->Linker->Input->Additional Dependencies Just enter the name of your .lib files
2.Project Properties->Linker->Input->Additional Dependencies 输入你的.lib文件名
3.Project Properties->C/C++->General->Additional Include Directories choose the folder where your .h files locate
3.Project Properties->C/C++->General->Additional Include Directories 选择.h文件所在的文件夹
回答by Virne
It is also possible to just drag'n'drop library file to project in Solution Explorer.
也可以将库文件拖放到解决方案资源管理器中的项目中。
回答by Dmitry Streblechenko
Do not statically link to any MAPI dlls. You must always dynamically load the MAPI system - look at the MFCMAPI source code to see how it is done: http://mfcmapi.codeplex.com/
不要静态链接到任何 MAPI dll。您必须始终动态加载 MAPI 系统 - 查看 MFCMAPI 源代码以了解它是如何完成的:http: //mfcmapi.codeplex.com/