如何在C ++链接器知道的.lib包含哪些功能?
例如在加速。我设置的包括的目录MSVC ++ 2010的升压根目录,并有一个的#include<升压/ regex.hpp>在
我的来源$ C $ C。我设置的库的目录升压\\阶段\\ lib中
但也有数百个文件,在那里 - 几个每个Boost库和这些升压: :正则表达式:
For example in Boost. I set an include directory in MSVC++2010 to the Boost root directory and have an #include <boost/regex.hpp>
in my source code. I set a library directory to boost\stage\lib
but there are hundreds of files in there – several for each Boost library and these for boost::regex:
libboost_regex-vc100-s-1_46.lib
libboost_regex-vc100-mt-gd-1_46.lib
libboost_regex-vc100-mt-1_46.lib
libboost_regex-vc100-mt-s-1_46.lib
libboost_regex-vc100-mt-s.lib
libboost_regex-vc100-s.lib
libboost_regex-vc100-mt.lib
libboost_regex-vc100-mt-gd.lib
如何MSVC知道所有的lib文件是正确的?如果它会扫描所有的人都为正确的函数签名,这是否意味着从两个不同的来源(而不是相互链接),它发生在定义具有相同名称和参数的功能,不能在一个lib文件夹编译2个不同的lib的?
How does MSVC know which of all lib files is the right one? If it scans all of them for the right function signatures, does that mean that 2 different lib's compiled from two different sources (not linked to each other) which happen to define functions with identical names and parameters cannot be in one lib folder?
和它如何知道哪个是所有这些不同的正则表达式的.lib的中吧?然后,用 1_46
每个文件在其文件名似乎等同于没有各自的文件,我可以安全地删除其中的两个?
And how does it know which is right among all those different regex .lib's? And then, each file with 1_46
in its filename seems to be identical to the respective file without, can I safely delete one of the two?
Boost库使用一些的黑暗魔法的选择库,从头部和编译器选项链接。我真的不知道所有的血淋淋的细节,但你可以看看升压/配置/ auto_link.hpp头的额外信息。
The boost libraries use some dark magic to select the libraries to link from the headers and compiler options. I don't really know all the gory details, but you can take a look at the boost/config/auto_link.hpp header for extra information.
在特定的,这似乎是难题中的重要部分:
In particular, this seems to be an important piece of the puzzle:
# pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib")