库导入:#pragma comment VS Visual Studio 项目输入 [英] Library importing: #pragma comment VS Visual studio project input

查看:32
本文介绍了库导入:#pragma comment VS Visual Studio 项目输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 使用#pragma comment(lib, "../../xxx.lib")
  2. 使用 Visual Studio 项目选项

两种方法的优缺点是什么?
我正在寻找更方便管理许多项目的方法.

What is the advantage and disadvantage between two method?
I'm finding way which is better convenient to manage for many projects.

微软推荐什么方法?

推荐答案

#pragma comment 的优点是您图书馆的用户不会忘记添加设置.或者添加错误的,在调试和发布版本与/MD 与/MT 版本之间的差异中迷失的情况并不少见.一个缺点是在某些情况下很难解决链接器问题.

The advantage of #pragma comment is that the user of your library cannot forget to add the setting. Or add the wrong one, it is not uncommon to get lost at the difference between the debug and release build and the /MD vs /MT build. One disadvantage is that troubleshooting linker problems can be difficult in some cases.

在解决方案中,为了方便起见,还有第三种方法很难被击败.右键单击需要库的项目,然后单击项目依赖项.勾选库项目.这可确保库项目始终在项目自动添加.lib 之前构建.

There's a third way that's hard to beat for convenience in a solution. Right-click the project that requires the library and click Project Dependencies. Tick the library project. This ensures that the library project is always built before the project and the .lib is automatically added.

这篇关于库导入:#pragma comment VS Visual Studio 项目输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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