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
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?
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?
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: