简体   繁体   English

将库添加到Visual Studio 2008 C ++项目

[英]Add Library to Visual Studio 2008 C++ Project

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" “未解析的外部符号_MAPIUninitialize @ 0在函数_main中引用”

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 link tab" and adding it there (which was - apparently - from an older version of Visual Studio). 我知道我需要链接到MAPI32.lib,但到目前为止我找到的指南已经指示进入“Visual Studio设置链接选项卡”并将其添加到那里(显然是 - 从较旧版本的Visual Studio)。 I can't find anything like that in the project properties linker or C/C++ sections of VS 2008. 我在VS 2008的项目属性链接器或C / C ++部分找不到类似的东西。

Where do I need to tell Visual Studio to use that library? 我在哪里需要告诉Visual Studio使用该库?

Thanks 谢谢

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)”

Project Properties->Linker->Input->Additional Dependencies 项目属性 - >链接器 - >输入 - >附加依赖项

You can also use #pragma comment( lib, "mapi32" ) in one of your source files. 您还可以在其中一个源文件中使用#pragma comment( lib, "mapi32" ) As noted MSDN here is a similar library addition using the pragma technique MSDN - Creating a Basic Winsock Application 如前所述,MSDN是使用编译指示技术MSDN - 创建基本Winsock应用程序的类似库添加

#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>

#pragma comment(lib, "Ws2_32.lib")

int main() {
  return 0;
}

Three simple steps: 三个简单的步骤:

  1. Project Properties->Linker->General->Additional Library Directories choose the folder which contains your .lib file 项目属性 - >链接器 - >常规 - >附加库目录选择包含.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文件所在的文件夹

也可以在解决方案资源管理器中将“拖放”库文件拖放到项目中。

Do not statically link to any MAPI dlls. 不要静态链接到任何MAPI dll。 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系统 - 查看MFCMAPI源代码以了解它是如何完成的: http//mfcmapi.codeplex.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM