No need to manually specify input libs for Boost. How is this achieved?

荒凉一梦 提交于 2019-12-24 17:43:37

问题


When using Boost with Visual C++, you can simply include the headers without ever bothering specifying which input libs to link. At build time, the IDE will somehow figure out the appropriate libs to link, be it release or debug, statically linking to CRT or dynamically linking to CRT. This makes using Boost quite convenient. I'm wondering how this is achieved. As an example, with a Multi-threaded Debug DLL (/MDd) configuration, the lib libboost_system-vc80-mt-gd-1_53.lib will be chosen and linked to automatically.


回答1:


The VC++ compiler has a feature that allows you to specify libraries to link directly in source code using pragma directives (https://msdn.microsoft.com/en-us/library/7f0aews7.aspx). It looks something like this:

#pragma comment(lib, "name-of-library")

Boost makes use of this feature, as you can see in this file.



来源:https://stackoverflow.com/questions/29648917/no-need-to-manually-specify-input-libs-for-boost-how-is-this-achieved

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!