【问题标题】:cmake Cannot link to custom boost when ubuntu boost package is installed安装ubuntu boost包时cmake无法链接到自定义boost
【发布时间】:2012-10-02 16:39:51
【问题描述】:

构建超高清 (http://ettus-apps.sourcerepo.com/redmine/ettus/projects/uhd/wiki) 下载链接https://github.com/EttusResearch/UHD-Mirror/zipball/release_003_004_003 我想选择我正在使用的 Boost 版本

使用 Ubuntu 11.10 64 位 我用 -fPIC 构建了一个自定义 Boost。我使用静态链接 我编辑 host/CMakeLists.txt 文件并添加了

set(Boost_USE_STATIC_LIBS ON)
set(BOOST_ROOT "/home/bastien/verisat/lib_boost_1_49_0_with_test_po_fPIC")
set(BOOST_INCLUDEDIR "/home/bastien/verisat/lib_boost_1_49_0_with_test_po_fPIC/include")
set(BOOST_LIBRARYDIR "/home/bastien/verisat/lib_boost_1_49_0_with_test_po_fPIC/lib")

在文件中已经存在的这 3 行之前

FIND_PACKAGE(Boost 1.49 COMPONENTS ${BOOST_REQUIRED_COMPONENTS})
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})

它总是链接到 /usr/lib 中的 boost 而不是指定的那个 当我删除 boost ubuntu 包时

sudo apt-get remove libboost-all-dev
sudo apt-get autoremove

然后它可以工作并指向指定的 boost 版本

我希望无需卸载默认的 boost 就可以这样做吗? 默认是 1.46,我的是 1.49,但是设置最低版本没有帮助

【问题讨论】:

    标签: ubuntu boost cmake


    【解决方案1】:

    你可以设置Boost_NO_SYSTEM_PATHS变量:

    #   Boost_NO_SYSTEM_PATHS        Set to TRUE to suppress searching in system
    #                                paths (or other locations outside of BOOST_ROOT
    #                                or BOOST_INCLUDEDIR).  Useful when specifying
    #                                BOOST_ROOT. Defaults to OFF.
    #                                  [Since CMake 2.8.3]
    

    【讨论】:

      【解决方案2】:

      在某处安装正确的版本并使用环境变量BOOST_ROOT 来指定它。 CMake 会在正常的系统路径之前尝试。

      【讨论】:

      • 我同意。我还在使用 cmake 的自定义提升而不是默认提升,并且在 FIND_PACKAGE(Boost... 之前设置 SET(BOOST_ROOT /dev/cpp/gcc47/boost) 效果很好。
      • 我已经做到了......如问题所示。但是直到我卸载了默认的ubuntu boost(如问题中所述...)
      • @user611191 这很奇怪。也许是因为它的版本相同,它更喜欢安装基础的版本?我不能说我以前遇到过。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-08
      • 1970-01-01
      • 2019-01-31
      • 1970-01-01
      • 2020-10-01
      • 2016-09-14
      • 1970-01-01
      相关资源
      最近更新 更多