如何让cmake找到可选的boost安装?

时间:2021-01-27 22:56:31

I have installed the most recent version of boost in /usr/local (with includes in /usr/local/include/boost and libraries in /usr/local/lib/boost) and I am now attempting to install Wt from source, but cmake (version 2.6) can't seem to find the boost installation. It tries to give helpful suggestions about setting BOOST_DIR and Boost_LIBRARYDIR, but I haven't been able to get it to work by tweaking these variables.

我已经在/usr/local中安装了最新版本的boost(包括/usr/local/include/boost和/usr/local/lib/boost中的库),现在我正在尝试从源代码中安装Wt,但是cmake(2.6版本)似乎找不到boost安装。它试图提供关于设置BOOST_DIR和Boost_LIBRARYDIR的有用建议,但我还没有通过调整这些变量使其工作。

The most recent error message that I get is that it can't find the libraries, but it seems to indicate that it is using "/usr/local/include" for the include path, which isn't correct (and I can't seem to fix it). Does anybody have a solution for this off the top of their head, or do I need to go mucking around inside cmake to figure it out?

我得到的最近的错误消息是它找不到库,但是它似乎表明它正在使用“/usr/local/include”来进行include路径,这是不正确的(而且我似乎无法修复它)。有人有办法解决这个问题吗?或者我需要在cmake里面找点东西解决这个问题吗?

11 个解决方案

#1


33  

You should have a look at FindBoost.cmake script, which handles Boost detection and setting up all Boost variables. It typically resides in /usr/share/cmake-2.6/Modules/. In it, you will find documentation. For instance:

您应该看看FindBoost。cmake脚本处理Boost检测和设置所有Boost变量。它通常位于/usr/share/cmake 2.6/ modules/中。在其中,您将找到文档。例如:

# These last three variables are available also as environment variables:
#
#   BOOST_ROOT or BOOSTROOT      The preferred installation prefix for searching for
#                                Boost.  Set this if the module has problems finding
#                                the proper Boost installation.
#

In contrast to BOOST_ROOT, the variables you are referring to are actually variables that are set by the FindBoost module. Note that you don't have to (and probably also don't want to) edit your CMake project configuration to set BOOST_ROOT. Instead, you should use the environment variable, e.g. calling

与BOOST_ROOT相反,您所引用的变量实际上是FindBoost模块设置的变量。注意,您不必(也可能不希望)编辑您的CMake项目配置来设置BOOST_ROOT。相反,您应该使用环境变量,例如调用

# BOOST_ROOT=/usr/local/... ccmake .

# BOOST_ROOT = / usr /地方/…ccmake。

#2


28  

I was finally able to get what I wanted with

我终于得到了我想要的东西

cmake -DCMAKE_INSTALL_PREFIX=$TARGET \
    -DBoost_NO_BOOST_CMAKE=TRUE \
    -DBoost_NO_SYSTEM_PATHS=TRUE \
    -DBOOST_ROOT:PATHNAME=$TARGET \
    -DBoost_LIBRARY_DIRS:FILEPATH=${TARGET}/lib

#3


12  

I had a similar issue, cmake finding vendor installed boost only, but my cluster has a locally installed version which is what I wanted it to use. RHEL 6

我有一个类似的问题,cmake find vendor only installed boost,但是我的集群有一个本地安装的版本,这正是我希望它使用的。RHEL 6

Anyway, looks like all the BOOSTROOT, BOOST_ROOT, Boost_DIR stuff would get annoyed unless one also sets Boost_NO_BOOST_CMAKE (e.g add to cmd line -DBoost_NO_BOOST_CMAKE=TRUE).

无论如何,看起来所有的BOOSTROOT、BOOST_ROOT、Boost_DIR之类的东西都会被惹恼,除非还设置了Boost_NO_BOOST_CMAKE (e)。g添加到cmd行-DBoost_NO_BOOST_CMAKE=TRUE)。

(I will concede the usefulness of CMake for multiplatform, but I can still hate it.)

(我承认CMake对于多平台来说是有用的,但我仍然讨厌它。)

#4


11  

Generally the most common mistake is NOT CLEANING YOUR BUILD DIR after adding new options. I have Boost installed from system packet manager. It's version is 1.49. I also downloaded Boost 1.53 and "installed" it under $HOME/installs .

通常最常见的错误是在添加新选项后不清理构建DIR。我安装了从系统包管理。的版本是1.49。我还下载了Boost 1.53并在$HOME/install下“安装”它。

The only thing that I had to do in my project was to: (I keep sources in my_project_directory/src )

在我的项目中,我要做的唯一一件事是:(我将源保存在my_project_directory/src中)

cd my_project_directory
mkdir build
cd build
cmake -DCMAKE_INCLUDE_PATH=$HOME/installs/include -DCMAKE_LIBRARY_PATH=$HOME/installs/lib ../src

And that's it. Ta bum tss.

就是这样。助教屁股tss。

But if I'd make after cd build -> cmake ../src it would set Boost from system path. Then doing cmake -DCMAKE_INCLUDE_PATH=$HOME/installs/include -DCMAKE_LIBRARY_PATH=$HOME/installs/lib ../src would change nothing.

但是如果我在cd构建之后做-> cmake…它将从系统路径设置Boost。然后执行cmake -DCMAKE_INCLUDE_PATH=$HOME/install /include -DCMAKE_LIBRARY_PATH=$HOME/install /lib。/ src会改变什么。

YOU HAVE TO CLEAN YOUR BUILD DIRECTORY. ( cd build && rm -rf * ;) )

您必须清理构建目录。(cd制作及rm -rf *)

#5


8  

There is a generic method to give cmake directions about where to find libs.

有一种通用的方法可以给cmake指明在哪里找到libs。

When looking for a lib, cmake looks first in the following variables :

在查找lib时,cmake首先考虑以下变量:

  • CMAKE_LIBRARY_PATH and LD_LIBRARY_PATH for libraries
  • 库的CMAKE_LIBRARY_PATH和LD_LIBRARY_PATH。
  • CMAKE_INCLUDE_PATH and INCLUDE_PATH for includes
  • 包含的CMAKE_INCLUDE_PATH和INCLUDE_PATH

If you declare your boost files in one of the env vars, cmake will find it. Example :

如果您在env vars中声明您的boost文件,cmake将找到它。例子:

export CMAKE_LIBRARY_PATH="/stuff/lib.boost.1.52/lib:$CMAKE_LIBRARY_PATH"
export CMAKE_INCLUDE_PATH="/stuff/lib.boost.1.52/include:$CMAKE_INCLUDE_PATH"

If it's too cumbersome, you can also use a nice installing tool I wrote that will do everything for you : C++ version manager

如果它太麻烦,您还可以使用我编写的一个很好的安装工具,它将为您完成所有工作:c++版本管理器

#6


8  

The Short version

You only need BOOST_ROOT, but you're going to want to disable searching the system for your local Boost if you have multiple installations or cross-compiling for iOS or Android. In which case add Boost_NO_SYSTEM_PATHS is set to false.

您只需要BOOST_ROOT,但是如果您有多个安装或iOS或Android的交叉编译,您将禁用搜索系统以获得本地增强。在这种情况下,添加Boost_NO_SYSTEM_PATHS被设置为false。

set( BOOST_ROOT "" CACHE PATH "Boost library path" )
set( Boost_NO_SYSTEM_PATHS on CACHE BOOL "Do not search system for Boost" )

Normally this is passed on the CMake command-line using the syntax -D<VAR>=value

通常,这是使用语法-D=value在CMake命令行上传递的

The Longer version

Officially speaking the FindBoost page states these variables should be used to 'hint' the location of boost.

根据FindBoost页面的官方说法,应该使用这些变量来“提示”boost的位置。

This module reads hints about search locations from variables:

此模块从变量中读取关于搜索位置的提示:

BOOST_ROOT             - Preferred installation prefix
 (or BOOSTROOT)
BOOST_INCLUDEDIR       - Preferred include directory e.g. <prefix>/include
BOOST_LIBRARYDIR       - Preferred library directory e.g. <prefix>/lib
Boost_NO_SYSTEM_PATHS  - Set to ON to disable searching in locations not
                         specified by these hint variables. Default is OFF.
Boost_ADDITIONAL_VERSIONS
                       - List of Boost versions not known to this module
                         (Boost install locations may contain the version)

This makes a theoretically correct incantation:

这是一个理论上正确的咒语:

cmake -DBoost_NO_SYSTEM_PATHS=TRUE \
      -DBOOST_ROOT=/path/to/boost-dir

When you compile from source

include( ExternalProject )

set( boost_URL "http://sourceforge.net/projects/boost/files/boost/1.63.0/boost_1_63_0.tar.bz2" )
set( boost_SHA1 "9f1dd4fa364a3e3156a77dc17aa562ef06404ff6" )
set( boost_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/third_party/boost )
set( boost_INCLUDE_DIR ${boost_INSTALL}/include )
set( boost_LIB_DIR ${boost_INSTALL}/lib )

ExternalProject_Add( boost
        PREFIX boost
        URL ${boost_URL}
        URL_HASH SHA1=${boost_SHA1}
        BUILD_IN_SOURCE 1
        CONFIGURE_COMMAND
        ./bootstrap.sh
        --with-libraries=filesystem
        --with-libraries=system
        --with-libraries=date_time
        --prefix=<INSTALL_DIR>
        BUILD_COMMAND
        ./b2 install link=static variant=release threading=multi runtime-link=static
        INSTALL_COMMAND ""
        INSTALL_DIR ${boost_INSTALL} )

set( Boost_LIBRARIES
        ${boost_LIB_DIR}/libboost_filesystem.a
        ${boost_LIB_DIR}/libboost_system.a
        ${boost_LIB_DIR}/libboost_date_time.a )
message( STATUS "Boost static libs: " ${Boost_LIBRARIES} )

Then when you call this script you'll need to include the boost.cmake script (mine is in the a subdirectory), include the headers, indicate the dependency, and link the libraries.

然后,当您调用这个脚本时,您需要包含这个boost。cmake脚本(我的脚本在a子目录中),包含头,指示依赖项,并链接库。

include( boost )
include_directories( ${boost_INCLUDE_DIR} )
add_dependencies( MyProject boost )
target_link_libraries( MyProject
                       ${Boost_LIBRARIES} )

#7


7  

I had a similar issue and I could use customized boost libraries by adding bewlow lines to my CMakeLists.txt:

我有一个类似的问题,我可以使用定制的boost库,将bewlow行添加到我的CMakeLists.txt:

set(Boost_NO_SYSTEM_PATHS TRUE) 
if (Boost_NO_SYSTEM_PATHS)
  set(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../3p/boost")
  set(BOOST_INCLUDE_DIRS "${BOOST_ROOT}/include")
  set(BOOST_LIBRARY_DIRS "${BOOST_ROOT}/lib")
endif (Boost_NO_SYSTEM_PATHS)
find_package(Boost REQUIRED regex date_time system filesystem thread graph program_options)
include_directories(${BOOST_INCLUDE_DIRS})

#8


3  

After digging around in cmake and experimenting, I determined that cmake was unhappy with the fact that all of my boost libraries were contained in /usr/local/lib/boost and not /usr/local/lib. Once I soft-linked them back out, the build worked.

在对cmake进行深入研究并进行实验之后,我确定cmake对我的所有boost库都包含在/usr/local/lib/boost中而不是/usr/local/lib这一事实感到不满一旦我将它们软连接起来,构建就成功了。

#9


1  

I also encountered the same problem, trying the hints here didnt help, unfortunately. The only thing helped is to download the newest version from the boost page, compiled and installed it as described here: http://piyushparkash.blogspot.de/2012/10/installing-boost-150-in-ubuntu-1210.html

我也遇到了同样的问题,不幸的是,尝试这里的提示没有帮助。唯一有帮助的是从boost页面下载最新版本,按照这里的描述进行编译和安装:http://piyushparkash.blogspot.de2/2//2012/10/installing-boot - 150-inubuntu-1210.html

in my case I worked with boost 1.53.

在我的案例中,我使用了boost 1.53。

#10


1  

I spent most of my evening trying to get this working. I tried all of the -DBOOST_* &c. directives with cmake, but it kept linking to my system Boost libraries, even after clearing and re-configuring my build area repeatedly. At the end I modified the generated Makefile and voided the cmake_check_build_system target to do nothing (like 'echo ""') so that it wouldn't overwrite my changes when I ran make, and then did 'grep -rl "lboost_python" * | xargs sed -i "s:-lboost_python:-L/opt/sw/gcc5/usr/lib/ -lboost_python:g' in my build/ directory to explicitly point all the build commands to the Boost installation I wanted to use. Finally, that worked.

我花了一晚上的大部分时间来尝试这个方法。我尝试了所有的-DBOOST_* &c。使用cmake的指令,但是它一直链接到我的系统Boost库,甚至在多次清除和重新配置我的构建区域之后。最后我修改生成的Makefile和空心cmake_check_build_system目标什么也不做(如“回声”“”),以便它不会覆盖我的改变当我跑,和那时的grep rl * | xargs sed -“lboost_python年代:-lboost_python:- l / opt / sw / gcc5 / usr / lib / -lboost_python:g’在我建立/目录明确指出所有的构建命令提高安装我想使用。最后,这一工作。

I acknowledge that it is an ugly kludge, but I am just putting it out here for the benefit of those who come up against the same brick wall, and just want to work around it and get work done.

我承认这是一个丑陋的拼凑物,但我只是为了那些站在同一面砖墙上的人的利益而把它放在这里,他们只是想绕过它,完成工作。

#11


0  

While configure could find my boost install, cmake could not.

配置可以找到我的boost安装,但cmake不能。

Locate FindBoost.cmake and look for LIBRARY_HINTS to see what sub-packages it is looking for. In my case it wanted the mpi and graph libs.

定位FindBoost。cmake并查找library_tips,看看它在寻找什么子包。在我的例子中,它需要mpi和graph libs。

 # Compute component-specific hints.
  set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "")
  if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python" OR
     ${COMPONENT} STREQUAL "graph_parallel")
    foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES})
      if(IS_ABSOLUTE "${lib}")
        get_filename_component(libdir "${lib}" PATH)
        string(REPLACE "\\" "/" libdir "${libdir}")
        list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT ${libdir})
      endif()
    endforeach()
  endif()

apt-cache search ... I installed the dev packages since I was building code, and the dev package drags in all the dependencies. I'm not so sure that a standard boost install needs openmpi, but this is OK for now.

apt-cache搜索…我安装了dev包,因为我在构建代码,而dev包在所有依赖项中拖拽。我不太确定标准的boost安装是否需要openmpi,但是现在还可以。

sudo apt-get install libboost-mpi-dev libboost-mpi-python-dev 
sudo apt-get install libboost-graph-parallel-dev

#1


33  

You should have a look at FindBoost.cmake script, which handles Boost detection and setting up all Boost variables. It typically resides in /usr/share/cmake-2.6/Modules/. In it, you will find documentation. For instance:

您应该看看FindBoost。cmake脚本处理Boost检测和设置所有Boost变量。它通常位于/usr/share/cmake 2.6/ modules/中。在其中,您将找到文档。例如:

# These last three variables are available also as environment variables:
#
#   BOOST_ROOT or BOOSTROOT      The preferred installation prefix for searching for
#                                Boost.  Set this if the module has problems finding
#                                the proper Boost installation.
#

In contrast to BOOST_ROOT, the variables you are referring to are actually variables that are set by the FindBoost module. Note that you don't have to (and probably also don't want to) edit your CMake project configuration to set BOOST_ROOT. Instead, you should use the environment variable, e.g. calling

与BOOST_ROOT相反,您所引用的变量实际上是FindBoost模块设置的变量。注意,您不必(也可能不希望)编辑您的CMake项目配置来设置BOOST_ROOT。相反,您应该使用环境变量,例如调用

# BOOST_ROOT=/usr/local/... ccmake .

# BOOST_ROOT = / usr /地方/…ccmake。

#2


28  

I was finally able to get what I wanted with

我终于得到了我想要的东西

cmake -DCMAKE_INSTALL_PREFIX=$TARGET \
    -DBoost_NO_BOOST_CMAKE=TRUE \
    -DBoost_NO_SYSTEM_PATHS=TRUE \
    -DBOOST_ROOT:PATHNAME=$TARGET \
    -DBoost_LIBRARY_DIRS:FILEPATH=${TARGET}/lib

#3


12  

I had a similar issue, cmake finding vendor installed boost only, but my cluster has a locally installed version which is what I wanted it to use. RHEL 6

我有一个类似的问题,cmake find vendor only installed boost,但是我的集群有一个本地安装的版本,这正是我希望它使用的。RHEL 6

Anyway, looks like all the BOOSTROOT, BOOST_ROOT, Boost_DIR stuff would get annoyed unless one also sets Boost_NO_BOOST_CMAKE (e.g add to cmd line -DBoost_NO_BOOST_CMAKE=TRUE).

无论如何,看起来所有的BOOSTROOT、BOOST_ROOT、Boost_DIR之类的东西都会被惹恼,除非还设置了Boost_NO_BOOST_CMAKE (e)。g添加到cmd行-DBoost_NO_BOOST_CMAKE=TRUE)。

(I will concede the usefulness of CMake for multiplatform, but I can still hate it.)

(我承认CMake对于多平台来说是有用的,但我仍然讨厌它。)

#4


11  

Generally the most common mistake is NOT CLEANING YOUR BUILD DIR after adding new options. I have Boost installed from system packet manager. It's version is 1.49. I also downloaded Boost 1.53 and "installed" it under $HOME/installs .

通常最常见的错误是在添加新选项后不清理构建DIR。我安装了从系统包管理。的版本是1.49。我还下载了Boost 1.53并在$HOME/install下“安装”它。

The only thing that I had to do in my project was to: (I keep sources in my_project_directory/src )

在我的项目中,我要做的唯一一件事是:(我将源保存在my_project_directory/src中)

cd my_project_directory
mkdir build
cd build
cmake -DCMAKE_INCLUDE_PATH=$HOME/installs/include -DCMAKE_LIBRARY_PATH=$HOME/installs/lib ../src

And that's it. Ta bum tss.

就是这样。助教屁股tss。

But if I'd make after cd build -> cmake ../src it would set Boost from system path. Then doing cmake -DCMAKE_INCLUDE_PATH=$HOME/installs/include -DCMAKE_LIBRARY_PATH=$HOME/installs/lib ../src would change nothing.

但是如果我在cd构建之后做-> cmake…它将从系统路径设置Boost。然后执行cmake -DCMAKE_INCLUDE_PATH=$HOME/install /include -DCMAKE_LIBRARY_PATH=$HOME/install /lib。/ src会改变什么。

YOU HAVE TO CLEAN YOUR BUILD DIRECTORY. ( cd build && rm -rf * ;) )

您必须清理构建目录。(cd制作及rm -rf *)

#5


8  

There is a generic method to give cmake directions about where to find libs.

有一种通用的方法可以给cmake指明在哪里找到libs。

When looking for a lib, cmake looks first in the following variables :

在查找lib时,cmake首先考虑以下变量:

  • CMAKE_LIBRARY_PATH and LD_LIBRARY_PATH for libraries
  • 库的CMAKE_LIBRARY_PATH和LD_LIBRARY_PATH。
  • CMAKE_INCLUDE_PATH and INCLUDE_PATH for includes
  • 包含的CMAKE_INCLUDE_PATH和INCLUDE_PATH

If you declare your boost files in one of the env vars, cmake will find it. Example :

如果您在env vars中声明您的boost文件,cmake将找到它。例子:

export CMAKE_LIBRARY_PATH="/stuff/lib.boost.1.52/lib:$CMAKE_LIBRARY_PATH"
export CMAKE_INCLUDE_PATH="/stuff/lib.boost.1.52/include:$CMAKE_INCLUDE_PATH"

If it's too cumbersome, you can also use a nice installing tool I wrote that will do everything for you : C++ version manager

如果它太麻烦,您还可以使用我编写的一个很好的安装工具,它将为您完成所有工作:c++版本管理器

#6


8  

The Short version

You only need BOOST_ROOT, but you're going to want to disable searching the system for your local Boost if you have multiple installations or cross-compiling for iOS or Android. In which case add Boost_NO_SYSTEM_PATHS is set to false.

您只需要BOOST_ROOT,但是如果您有多个安装或iOS或Android的交叉编译,您将禁用搜索系统以获得本地增强。在这种情况下,添加Boost_NO_SYSTEM_PATHS被设置为false。

set( BOOST_ROOT "" CACHE PATH "Boost library path" )
set( Boost_NO_SYSTEM_PATHS on CACHE BOOL "Do not search system for Boost" )

Normally this is passed on the CMake command-line using the syntax -D<VAR>=value

通常,这是使用语法-D=value在CMake命令行上传递的

The Longer version

Officially speaking the FindBoost page states these variables should be used to 'hint' the location of boost.

根据FindBoost页面的官方说法,应该使用这些变量来“提示”boost的位置。

This module reads hints about search locations from variables:

此模块从变量中读取关于搜索位置的提示:

BOOST_ROOT             - Preferred installation prefix
 (or BOOSTROOT)
BOOST_INCLUDEDIR       - Preferred include directory e.g. <prefix>/include
BOOST_LIBRARYDIR       - Preferred library directory e.g. <prefix>/lib
Boost_NO_SYSTEM_PATHS  - Set to ON to disable searching in locations not
                         specified by these hint variables. Default is OFF.
Boost_ADDITIONAL_VERSIONS
                       - List of Boost versions not known to this module
                         (Boost install locations may contain the version)

This makes a theoretically correct incantation:

这是一个理论上正确的咒语:

cmake -DBoost_NO_SYSTEM_PATHS=TRUE \
      -DBOOST_ROOT=/path/to/boost-dir

When you compile from source

include( ExternalProject )

set( boost_URL "http://sourceforge.net/projects/boost/files/boost/1.63.0/boost_1_63_0.tar.bz2" )
set( boost_SHA1 "9f1dd4fa364a3e3156a77dc17aa562ef06404ff6" )
set( boost_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/third_party/boost )
set( boost_INCLUDE_DIR ${boost_INSTALL}/include )
set( boost_LIB_DIR ${boost_INSTALL}/lib )

ExternalProject_Add( boost
        PREFIX boost
        URL ${boost_URL}
        URL_HASH SHA1=${boost_SHA1}
        BUILD_IN_SOURCE 1
        CONFIGURE_COMMAND
        ./bootstrap.sh
        --with-libraries=filesystem
        --with-libraries=system
        --with-libraries=date_time
        --prefix=<INSTALL_DIR>
        BUILD_COMMAND
        ./b2 install link=static variant=release threading=multi runtime-link=static
        INSTALL_COMMAND ""
        INSTALL_DIR ${boost_INSTALL} )

set( Boost_LIBRARIES
        ${boost_LIB_DIR}/libboost_filesystem.a
        ${boost_LIB_DIR}/libboost_system.a
        ${boost_LIB_DIR}/libboost_date_time.a )
message( STATUS "Boost static libs: " ${Boost_LIBRARIES} )

Then when you call this script you'll need to include the boost.cmake script (mine is in the a subdirectory), include the headers, indicate the dependency, and link the libraries.

然后,当您调用这个脚本时,您需要包含这个boost。cmake脚本(我的脚本在a子目录中),包含头,指示依赖项,并链接库。

include( boost )
include_directories( ${boost_INCLUDE_DIR} )
add_dependencies( MyProject boost )
target_link_libraries( MyProject
                       ${Boost_LIBRARIES} )

#7


7  

I had a similar issue and I could use customized boost libraries by adding bewlow lines to my CMakeLists.txt:

我有一个类似的问题,我可以使用定制的boost库,将bewlow行添加到我的CMakeLists.txt:

set(Boost_NO_SYSTEM_PATHS TRUE) 
if (Boost_NO_SYSTEM_PATHS)
  set(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../3p/boost")
  set(BOOST_INCLUDE_DIRS "${BOOST_ROOT}/include")
  set(BOOST_LIBRARY_DIRS "${BOOST_ROOT}/lib")
endif (Boost_NO_SYSTEM_PATHS)
find_package(Boost REQUIRED regex date_time system filesystem thread graph program_options)
include_directories(${BOOST_INCLUDE_DIRS})

#8


3  

After digging around in cmake and experimenting, I determined that cmake was unhappy with the fact that all of my boost libraries were contained in /usr/local/lib/boost and not /usr/local/lib. Once I soft-linked them back out, the build worked.

在对cmake进行深入研究并进行实验之后,我确定cmake对我的所有boost库都包含在/usr/local/lib/boost中而不是/usr/local/lib这一事实感到不满一旦我将它们软连接起来,构建就成功了。

#9


1  

I also encountered the same problem, trying the hints here didnt help, unfortunately. The only thing helped is to download the newest version from the boost page, compiled and installed it as described here: http://piyushparkash.blogspot.de/2012/10/installing-boost-150-in-ubuntu-1210.html

我也遇到了同样的问题,不幸的是,尝试这里的提示没有帮助。唯一有帮助的是从boost页面下载最新版本,按照这里的描述进行编译和安装:http://piyushparkash.blogspot.de2/2//2012/10/installing-boot - 150-inubuntu-1210.html

in my case I worked with boost 1.53.

在我的案例中,我使用了boost 1.53。

#10


1  

I spent most of my evening trying to get this working. I tried all of the -DBOOST_* &c. directives with cmake, but it kept linking to my system Boost libraries, even after clearing and re-configuring my build area repeatedly. At the end I modified the generated Makefile and voided the cmake_check_build_system target to do nothing (like 'echo ""') so that it wouldn't overwrite my changes when I ran make, and then did 'grep -rl "lboost_python" * | xargs sed -i "s:-lboost_python:-L/opt/sw/gcc5/usr/lib/ -lboost_python:g' in my build/ directory to explicitly point all the build commands to the Boost installation I wanted to use. Finally, that worked.

我花了一晚上的大部分时间来尝试这个方法。我尝试了所有的-DBOOST_* &c。使用cmake的指令,但是它一直链接到我的系统Boost库,甚至在多次清除和重新配置我的构建区域之后。最后我修改生成的Makefile和空心cmake_check_build_system目标什么也不做(如“回声”“”),以便它不会覆盖我的改变当我跑,和那时的grep rl * | xargs sed -“lboost_python年代:-lboost_python:- l / opt / sw / gcc5 / usr / lib / -lboost_python:g’在我建立/目录明确指出所有的构建命令提高安装我想使用。最后,这一工作。

I acknowledge that it is an ugly kludge, but I am just putting it out here for the benefit of those who come up against the same brick wall, and just want to work around it and get work done.

我承认这是一个丑陋的拼凑物,但我只是为了那些站在同一面砖墙上的人的利益而把它放在这里,他们只是想绕过它,完成工作。

#11


0  

While configure could find my boost install, cmake could not.

配置可以找到我的boost安装,但cmake不能。

Locate FindBoost.cmake and look for LIBRARY_HINTS to see what sub-packages it is looking for. In my case it wanted the mpi and graph libs.

定位FindBoost。cmake并查找library_tips,看看它在寻找什么子包。在我的例子中,它需要mpi和graph libs。

 # Compute component-specific hints.
  set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "")
  if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python" OR
     ${COMPONENT} STREQUAL "graph_parallel")
    foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES})
      if(IS_ABSOLUTE "${lib}")
        get_filename_component(libdir "${lib}" PATH)
        string(REPLACE "\\" "/" libdir "${libdir}")
        list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT ${libdir})
      endif()
    endforeach()
  endif()

apt-cache search ... I installed the dev packages since I was building code, and the dev package drags in all the dependencies. I'm not so sure that a standard boost install needs openmpi, but this is OK for now.

apt-cache搜索…我安装了dev包,因为我在构建代码,而dev包在所有依赖项中拖拽。我不太确定标准的boost安装是否需要openmpi,但是现在还可以。

sudo apt-get install libboost-mpi-dev libboost-mpi-python-dev 
sudo apt-get install libboost-graph-parallel-dev