<legend id='ODWj8'><style id='ODWj8'><dir id='ODWj8'><q id='ODWj8'></q></dir></style></legend>
    <tfoot id='ODWj8'></tfoot>

  • <i id='ODWj8'><tr id='ODWj8'><dt id='ODWj8'><q id='ODWj8'><span id='ODWj8'><b id='ODWj8'><form id='ODWj8'><ins id='ODWj8'></ins><ul id='ODWj8'></ul><sub id='ODWj8'></sub></form><legend id='ODWj8'></legend><bdo id='ODWj8'><pre id='ODWj8'><center id='ODWj8'></center></pre></bdo></b><th id='ODWj8'></th></span></q></dt></tr></i><div id='ODWj8'><tfoot id='ODWj8'></tfoot><dl id='ODWj8'><fieldset id='ODWj8'></fieldset></dl></div>
      <bdo id='ODWj8'></bdo><ul id='ODWj8'></ul>

      1. <small id='ODWj8'></small><noframes id='ODWj8'>

        C++ 链接器如何知道哪个 .lib 包含哪些函数?

        How does the C++ linker know which .lib contains which functions?(C++ 链接器如何知道哪个 .lib 包含哪些函数?)
        • <bdo id='CAUmk'></bdo><ul id='CAUmk'></ul>

          <i id='CAUmk'><tr id='CAUmk'><dt id='CAUmk'><q id='CAUmk'><span id='CAUmk'><b id='CAUmk'><form id='CAUmk'><ins id='CAUmk'></ins><ul id='CAUmk'></ul><sub id='CAUmk'></sub></form><legend id='CAUmk'></legend><bdo id='CAUmk'><pre id='CAUmk'><center id='CAUmk'></center></pre></bdo></b><th id='CAUmk'></th></span></q></dt></tr></i><div id='CAUmk'><tfoot id='CAUmk'></tfoot><dl id='CAUmk'><fieldset id='CAUmk'></fieldset></dl></div>
          • <tfoot id='CAUmk'></tfoot>
          • <small id='CAUmk'></small><noframes id='CAUmk'>

                  <tbody id='CAUmk'></tbody>
              • <legend id='CAUmk'><style id='CAUmk'><dir id='CAUmk'><q id='CAUmk'></q></dir></style></legend>

                  本文介绍了C++ 链接器如何知道哪个 .lib 包含哪些函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  例如在 Boost 中.我将 MSVC++2010 中的 include 目录设置为 Boost 根目录,并在我的源代码中有一个 #include <boost/regex.hpp>.我将一个 library 目录设置为 booststagelib 但里面有数百个文件——每个 Boost 库有几个文件,这些用于 boost::regex:

                  <前>libboost_regex-vc100-s-1_46.liblibboost_regex-vc100-mt-gd-1_46.liblibboost_regex-vc100-mt-1_46.liblibboost_regex-vc100-mt-s-1_46.liblibboost_regex-vc100-mt-s.liblibboost_regex-vc100-s.liblibboost_regex-vc100-mt.liblibboost_regex-vc100-mt-gd.lib

                  MSVC 如何知道所有 lib 文件中哪个是正确的?如果它扫描所有这些函数签名是否正确,这是否意味着从两个不同的源(彼此没有链接)编译的 2 个不同的 lib 恰好定义了具有相同名称和参数的函数不能在一个 lib 文件夹中?

                  它如何知道在所有这些不同的正则表达式 .lib 中哪个是正确的?然后,每个文件名中带有 1_46 的文件似乎都与相应的文件相同,没有,我可以安全地删除两者之一吗?

                  解决方案

                  boost 库使用一些黑魔法从头文件和编译器选项中选择要链接的库.我真的不知道所有的血腥细节,但您可以查看 boost/config/auto_link.hpp 标头以获取更多信息.

                  特别是,这似乎是拼图的一个重要部分:

                  # 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")

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

                  #  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")
                  

                  这篇关于C++ 链接器如何知道哪个 .lib 包含哪些函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to limit the number of running instances in C++(C++中如何限制运行实例的数量)
                  Using boost::asio::async_read with stdin?(将 boost::asio::async_read 与 stdin 一起使用?)
                  How to find out what dependencies (i.e other Boost libraries) a particular Boost library requires?(如何找出特定 Boost 库需要哪些依赖项(即其他 Boost 库)?)
                  What#39;s the purpose of a leading quot;::quot; in a C++ method call(引导“::的目的是什么?在 C++ 方法调用中)
                  Boost Spirit x3: parse into structs(Boost Spirit x3:解析为结构体)
                  How boost auto-linking makes choice?(boost自动链接如何做出选择?)

                      <bdo id='DZ1tQ'></bdo><ul id='DZ1tQ'></ul>

                      • <i id='DZ1tQ'><tr id='DZ1tQ'><dt id='DZ1tQ'><q id='DZ1tQ'><span id='DZ1tQ'><b id='DZ1tQ'><form id='DZ1tQ'><ins id='DZ1tQ'></ins><ul id='DZ1tQ'></ul><sub id='DZ1tQ'></sub></form><legend id='DZ1tQ'></legend><bdo id='DZ1tQ'><pre id='DZ1tQ'><center id='DZ1tQ'></center></pre></bdo></b><th id='DZ1tQ'></th></span></q></dt></tr></i><div id='DZ1tQ'><tfoot id='DZ1tQ'></tfoot><dl id='DZ1tQ'><fieldset id='DZ1tQ'></fieldset></dl></div>
                      • <legend id='DZ1tQ'><style id='DZ1tQ'><dir id='DZ1tQ'><q id='DZ1tQ'></q></dir></style></legend>
                          <tfoot id='DZ1tQ'></tfoot>
                            <tbody id='DZ1tQ'></tbody>

                          <small id='DZ1tQ'></small><noframes id='DZ1tQ'>