静态链接使用 fPIC 编译的 libgomp.a 时找不到符号的版本节点

问题描述 投票:0回答:0

我正在尝试使用

-fPIC
重新编译旧版本的 gcc/gfortran,以便我能够使用 -fPIC 编译对象静态链接库

# gcc/gfortran configured and compiled with
./configure --disable-multilib --with-pic CFLAGS=-fPIC CXXFLAGS=-fPIC -prefix=~/gcc-7.5.0 FFLAGS=-fPIC

但是在链接过程中遇到

libgomp
OpenMP 问题

# linking final binary
gcc -s -shared -Wl,--no-undefined -Wl,-rpath='$ORIGIN' -lstdc++ -Wl,-rpath-link,/usr/local/MATLAB/R2019b/bin/glnxa64 -Wl,--version-script,/usr/local/MATLAB/R2019b/extern/lib/glnxa64/c_exportsmexfileversion.map dmumpsmex.o c_mexapi_version.o -L/usr/local/MATLAB/R2019b/sys/os/glnxa64 -L/usr/local/MATLAB/R2019b/bin/glnxa64 -Wl,-Bstatic -Imumps-5.5.1/include -Lmumps-5.5.1/lib -ldmumps -lmumps_common -Imumps-5.5.1/libseq -Lmumps-5.5.1/libseq -lmpiseq -Lmumps-5.5.1/PORD/lib -lpord  -lgomp -lpthread -lgfortran -lm -lquadmath -Wl,-Bdynamic -L/usr/local/MATLAB/R2019b/sys/os/glnxa64 -L/usr/local/MATLAB/R2019b/bin/glnxa64 /home/user/mumps/lapack-3.11.0/libblas.a /home/user/mumps/lapack-3.11.0/liblapack.a -lmx -lmex -lmat -o dmumpsmex.mexa64

/usr/bin/ld: version node not found for symbol omp_set_nest_lock@@OMP_3.0
/usr/bin/ld: failed to set dynamic section sizes: Bad value

如果我检查 libgomp 中的符号,这肯定是定义的,并且 libgomp 没有多重链接。动态链接 (.so) 有效,但静态链接 (.a) 无效,所以我不太确定问题出在哪里?

gcc linker openmp ld fpic
© www.soinside.com 2019 - 2024. All rights reserved.