<legend id='AH1wm'><style id='AH1wm'><dir id='AH1wm'><q id='AH1wm'></q></dir></style></legend>

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

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

      1. <tfoot id='AH1wm'></tfoot>
          <bdo id='AH1wm'></bdo><ul id='AH1wm'></ul>
      2. CMake FIND_PACKAGE 成功但返回错误的路径

        时间:2023-08-27
        <legend id='lE3kX'><style id='lE3kX'><dir id='lE3kX'><q id='lE3kX'></q></dir></style></legend>
          <bdo id='lE3kX'></bdo><ul id='lE3kX'></ul>

          <tfoot id='lE3kX'></tfoot>

        • <small id='lE3kX'></small><noframes id='lE3kX'>

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

                    <tbody id='lE3kX'></tbody>
                • 本文介绍了CMake FIND_PACKAGE 成功但返回错误的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 CMakeLists.txt 中的以下代码将 CMake 2.8.6 链接到 boost::program_options

                  I'm trying to have CMake 2.8.6 link to boost::program_options using the following code in my CMakeLists.txt

                  FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED)
                  INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIR})
                  
                  ADD_EXECUTABLE (segment segment.cpp)
                  TARGET_LINK_LIBRARIES (segment ${Boost_LIBRARIES})
                  

                  find 命令似乎成功了,但将错误的目录传递给了链接器.包裹实际上在:

                  The find command seems to succeed but passes the wrong directory to the linker. The package is actually in:

                  `/usr/lib64/libboost_program_options-mt.so.5`
                  

                  但是CMakeFiles/segment.dir/link.txt列出了以下内容:

                  /cm/shared/apps/gcc/4.4.6/bin/c++       CMakeFiles/segment.dir/segment.cpp.o  -o segment -rdynamic /usr/lib64/lib64/libboost_program_options-mt.so.5 -lpthread -lrt -Wl,-rpath,/usr/lib64/lib64
                  

                  注意路径中额外的 lib64.此外,路径前面的 -l 标志似乎丢失了.

                  Note the extra lib64 in the path. Also, the -l flag in front of the path seems to be missing.

                  当运行 CMake 时,它报告它正确地找到了包,并且 {$Boost_LIBRARIES} 变量似乎列出了正确的库:

                  When running CMake it reports that it correctly finds the package, and the {$Boost_LIBRARIES} variable seems to list the correct libs:

                  Boost  found.
                  Found Boost components:
                     program_options
                  ${Boost_LIBRARIES} - optimized;boost_program_options-mt-shared;debug;boost_program_options-mt-shared-debug
                  

                  生成的 CMakeCache.txt 文件以:

                  The generated CMakeCache.txt file starts with:

                  //The directory containing a CMake configuration file for Boost.
                  Boost_DIR:PATH=/usr/lib64/boost
                  
                  //Boost include directory
                  Boost_INCLUDE_DIR:FILEPATH=/usr/include
                  

                  这似乎是正确的.但是当运行 make 它使用上面link.txt中的路径时,我得到了错误:

                  Which seems to be correct. But when running make it uses the path in link.txt above and I get the error:

                  make[2]: *** No rule to make target `/usr/lib64/lib64/libboost_program_options-mt.so.5', needed by `segment'.  Stop.
                  make[1]: *** [CMakeFiles/segment.dir/all] Error 2
                  make: *** [all] Error 2
                  

                  什么可能导致将子目录额外注入到路径中?什么可能导致以这种方式生成link.txt?我该如何解决(或解决它)?

                  What might cause this extra injection of a subdir into the path? What might cause link.txt to be generated in this way? And how do I fix it (or work around it)?

                  推荐答案

                  当使用一些旧版本的 boost 和 cmake-2.8.6-rc2 或更高版本时会出现这个问题,其中 boost 包发现代码已更改.

                  This problem occurs when using some older versions of boost with cmake-2.8.6-rc2 or later, where the boost package finding code was changed.

                  该问题可以通过在 cmake 命令行中指定 -DBoost_NO_BOOST_CMAKE=ON 来解决.

                  The problem can be worked around by specifying -DBoost_NO_BOOST_CMAKE=ON on the cmake command line.

                  引入这个问题的实际 commit 是 7da796d1fdd7cca07df733d010cd343f6f8787a9,可以是 在此处查看.

                  The actual commit where this problem is introduced is 7da796d1fdd7cca07df733d010cd343f6f8787a9, and can be viewed here.

                  这篇关于CMake FIND_PACKAGE 成功但返回错误的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何创建一个依赖于外部头文件的 cmake 头文件库? 下一篇:用于应用程序本地部署的 MSVC 2015 通用 CRT

                  相关文章

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

                • <small id='SV4xP'></small><noframes id='SV4xP'>

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

                    <tfoot id='SV4xP'></tfoot>