我试图编译一些开源代码,它给出了上面显示的以下错误。
我想这意味着代码正在进行实际编译,但在链接期间无法找到此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