How does the C++ linker know which .lib contains which functions?

前端 未结 3 1950
时光说笑
时光说笑 2020-12-10 03:12

For example in Boost. I set an include directory in MSVC++2010 to the Boost root directory and have an #include in my source co

3条回答
  •  鱼传尺愫
    2020-12-10 03:28

    Two libraries containing identical functions isn't a problem. The linker only looks at the libraries that it's told to look at. If two of them contain identical functions, it'll give an error message (this is actually fairly common, usually due to conflict between static and dynamic linking with the standard library).

    You can tell the linker which libraries to look at in a number of ways -- on the linker command line (possibly as generated by the IDE) and via #pragma comment(lib, "libname.lib") are the two most common though.

提交回复
热议问题