C ++ Visual Studio:使用注释注释链接 [英] C++ Visual Studio: linking using pragma comment

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

问题描述

我遇到了一段使用#pragma comment(lib, libraryname)的代码。

I came across a piece of code which uses #pragma comment(lib, "libraryname").

为什么使用这种用法而不是仅仅链接库从属性菜单?在什么情况下需要这种用法?我在Windows中使用C ++ Visual Studio 2010

Why this type of usage as opposed to just linking the library from the properties menu? In what situations is this usage called for? I am in windows using C++ Visual Studio 2010.

很高兴看到一个需要这种用法的示例。

It would be nice to see an example which calls for this type of usage.

推荐答案

库编写器可以在公共头文件(.h)中放置 #pragma comment(lib,...)命令。在这种情况下,客户端无需将此库添加到链接器依赖项列表。通过在程序中包含h文件,客户端将自动链接到所需的库。

The library writer can place a #pragma comment(lib, ...) command in the public header (.h) file. In this case, the client doesn't need to add this library to the linker dependencies list. By including an h-file in the program, the client is automatically linked to the required library.

这篇关于C ++ Visual Studio:使用注释注释链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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