未定义引用`typeinfo for boost :: mpi :: exception'

时间:2016-02-15 15:43:59

标签: c++ boost cmake ubuntu-14.04

我试图编译一些开源代码,它给出了上面显示的以下错误。

我想这意味着代码正在进行实际编译,但在链接期间无法找到此boost::mpi::exception库。

但是我安装了libboost-mpi-dev并成功编译了boost::mpi的一些玩具示例,例如:

#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
#include <iostream>
namespace mpi = boost::mpi;
int main()
{
  mpi::environment env;
  mpi::communicator world;
  std::cout << "I am process " << world.rank() << " of " << world.size()
            << "." << std::endl;
  return 0;
}

使用CMakeList.txt文件编译开源代码。 我觉得我的boost 1.54(标准Ubuntu 14.04版本)不向下兼容boost 1.49,作者在其CMakeList.txt中指定为最低要求:

find_package(MPI)
if( MPI_FOUND )
    find_package(Boost 1.49 COMPONENTS mpi)
    if( Boost_MPI_FOUND )
        message(status "** MPI support enabled")
        message(status "** MPI Libraries: ${MPI_LIBRARIES}")

        ### When I uncomment the next line the Code actually compiles however only without MPI ####
        add_definitions(-DUSE_MPI)
    else ()
        message(status "** MPI library found but Boost MPI not available; MPI support disabled.")
    endif ()
endif ()
find_package(Boost 1.49 COMPONENTS system filesystem REQUIRED)

message(status "** Boost Include: ${Boost_INCLUDE_DIR}")
message(status "** Boost Libraries: ${Boost_LIBRARY_DIRS}")
message(status "** Boost Libraries: ${Boost_LIBRARIES}")
[...]

不幸的是,即使编译boost 1.49也无法帮助我,因为构建CMakeList.txt只会找到全局安装的boost 1.54而不是本地安装的boost 1.49虽然我将本地路径添加到LD_LIBRARY_PATH。

有谁知道如何解决这个问题?

PS:这是make期间出现的完整错误消息:

CMakeFiles/ColorDenoising.dir/ColorDenoising.cpp.o:(.rodata._ZTIN5boost16exception_detail19error_info_injectorINS_3mpi9exceptionEEE[_ZTIN5boost16exception_detail19error_info_injectorINS_3mpi9exceptionEEE]+0x18): undefined reference to `typeinfo for boost::mpi::exception'
    collect2: error: ld returned 1 exit status
    make[2]: *** [Apps/ColorDenoising/ColorDenoising] Error 1
    make[1]: *** [Apps/ColorDenoising/CMakeFiles/ColorDenoising.dir/all] Error 2
    make[1]: *** Waiting for unfinished jobs....
    Linking CXX executable MultiLabel
    [100%] Built target MultiLabel
    make: *** [all] Error 2

0 个答案:

没有答案