错误记录:
/usr/bin/ld: xx.o: undefined reference to symbol '_ZN3MPI8Datatype4FreeEv'
//usr/lib/libmpi_cxx.so.1: error adding symbols: DSO missing from command line
解决方法:
在CMakeLists.txt中,加上:
ADD_EXECUTABLE(xxx xxx.cpp )
TARGET_LINK_LIBRARIES(xxx mpi_cxx )
#ORB-SLAM3中
target_link_libraries(${PROJECT_NAME}
mpi_cxx
)
拓展:
网上是这样说的:mpic++:Open MPI C++ wrapper compiler mpicxx:Compiles and links MPI programs written in C++,
其实就是一个脚本,将原来的C++编译器包装了一下,给定了一些MPI相关的编译链接参数,包括INCLUDE和LIB路径之类的,方便使用。可以自己用代码编辑器打开查看.
输入mpic++ -show,你就知道mpic++其实包装了g++命令
$ mpicxx -show
g++ -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -