C++ 对pthread_atfork的未定义引用`

C++ 对pthread_atfork的未定义引用`,c++,gcc,g++,openmpi,C++,Gcc,G++,Openmpi,使用ubuntu中的g++版本4.9,编译C++源文件名为“代码>测试.CPP 时需要一个名为 -WL,-rPATH链接,/home /MUMY/OpenMPI/Bug/LIB < /C> >如下: g++ test.cpp -lUtils -Wl,-rpath-link,/home/dummy/openmpi/build/lib 抛出一个错误/home/dummy/openmpi/build/lib/libopen-pal.so.20:未定义对pthread_atfork的引用 我向g++传

使用ubuntu中的g++版本4.9,编译C++源文件名为“代码>测试.CPP 时需要一个名为(这需要打开MPI共享库,因此参数<>代码> -WL,-rPATH链接,/home /MUMY/OpenMPI/Bug/LIB < /C> >如下:

g++ test.cpp -lUtils -Wl,-rpath-link,/home/dummy/openmpi/build/lib
抛出一个错误
/home/dummy/openmpi/build/lib/libopen-pal.so.20:未定义对pthread_atfork的引用


我向g++传递了
-pthread
-lpthread
,但这些都没有解决错误。

“我传递了-pthread和-lpthread”您使用的完整行是什么。顺序问题。我尝试了许多组合,但都没有成功,即:
g++test.cpp-pthread-lUtils-Wl,-rpath链接,/home/dummy/openmpi/build/lib
g++test.cpp-lpthread-lUtils-Wl,-rpath链接,/home/dummy/openmpi/build/lib
g++test.cpp-lUtils-Wl,-rpath链接,/home/dummy/openmpi/build/lib-pthread
g++test.cpp-lUtils-Wl,-rpath链接,/home/dummy/openmpi/build/lib-lpthread
g++test.cpp-lpthread-lUtils
链接到pthread,然后链接到utils-这意味着utils找不到pthread库。反过来说,您是否在同一台机器上构建了OpenMPI(以及哪个版本?)?在那之后你升级过任何软件包吗?ldd/home/dummy/openmpi/build/lib/libopen-pal.so.20说明了什么?
test.cpp
是否调用任何MPI子例程?如果改为使用
mpicxx
链接会怎么样?@UKMonkey:g++test.cpp-lpthread-lUtils和
g++test.cpp-lUtils-lpthread
都不起作用。