Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux gcc未定义对'pthread_atfork';_Linux_Gcc_Linker_Pthreads - Fatal编程技术网

Linux gcc未定义对'pthread_atfork';

Linux gcc未定义对'pthread_atfork';,linux,gcc,linker,pthreads,Linux,Gcc,Linker,Pthreads,我正在尝试在x86_64体系结构上安装gcc 7.2.0的optware ng上编译openssl的最新版本 系统有两个libpthread,一个在/lib:/usr/lib:/lib64:/usr/lib64中(相互链接)。并且在opt软件中有一个安装在/opt/lib:/opt/lib64中(也相互链接) 编译进行得很顺利,但在链接时出现以下错误: gcc -pthread -m64 -Wa,--noexecstack -Wall -O3 -L. -o apps/openssl apps/a

我正在尝试在x86_64体系结构上安装gcc 7.2.0的optware ng上编译openssl的最新版本

系统有两个libpthread,一个在/lib:/usr/lib:/lib64:/usr/lib64中(相互链接)。并且在opt软件中有一个安装在/opt/lib:/opt/lib64中(也相互链接)

编译进行得很顺利,但在链接时出现以下错误:

gcc -pthread -m64 -Wa,--noexecstack -Wall -O3 -L. -o apps/openssl apps/asn1pars.o apps/ca.o apps/ciphers.o apps/cms.o apps/crl.o apps/crl2p7.o apps/dgst.o apps/dhparam.o apps/dsa.o apps/dsaparam.o apps/ec.o apps/ecparam.o apps/enc.o apps/engine.o apps/errstr.o apps/gendsa.o apps/genpkey.o apps/genrsa.o apps/nseq.o apps/ocsp.o apps/openssl.o apps/passwd.o apps/pkcs12.o apps/pkcs7.o apps/pkcs8.o apps/pkey.o apps/pkeyparam.o apps/pkeyutl.o apps/prime.o apps/rand.o apps/rehash.o apps/req.o apps/rsa.o apps/rsautl.o apps/s_client.o apps/s_server.o apps/s_time.o apps/sess_id.o apps/smime.o apps/speed.o apps/spkac.o apps/srp.o apps/storeutl.o apps/ts.o apps/verify.o apps/version.o apps/x509.o apps/libapps.a -lssl -lcrypto -ldl -pthread
./libcrypto.so: undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
将-v添加到gcc的输出中:

COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/lto-wrapper
Target: x86_64-buildroot-linux-gnu
Configured with: ../gcc-7.2.0/configure --build=x86_64-pc-linux-gnu --host=x86_64-buildroot-linux-gnu --target=x86_64-buildroot-linux-gnu --prefix=/opt --disable-nls --disable-static --with-as=/opt/bin/as --with-ld=/opt/bin/ld --enable-languages=c,c++,go --disable-multilib --disable-werror --with-gxx-include-dir=/opt/include/c++/7.2.0 --disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --enable-libquadmath --enable-tls --disable-libmudflap --enable-threads --without-isl --without-cloog --disable-decimal-float --with-arch=nocona --enable-shared --disable-libgomp --with-gmp=/home/jenkins/Optware-ng/buildroot-x86_64/staging/opt --with-mpfr=/home/jenkins/Optware-ng/buildroot-x86_64/staging/opt --with-mpc=/home/jenkins/Optware-ng/buildroot-x86_64/staging/opt --with-system-zlib
Thread model: posix
gcc version 7.2.0 (GCC) 
COMPILER_PATH=/opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/:/opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/:/opt/libexec/gcc/x86_64-buildroot-linux-gnu/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/bin/
LIBRARY_PATH=/opt/lib64/../lib64/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/lib64/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/lib/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-pthread' '-m64' '-Wall' '-O3' '-L.' '-o' 'apps/openssl' '-pthread' '-mtune=generic' '-march=nocona'
 /opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/collect2 -plugin /opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/liblto_plugin.so -plugin-opt=/opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/cc5Txvvm.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /opt/lib64/ld-linux-x86-64.so.2 -o apps/openssl /opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/lib/crt1.o /opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/lib/crti.o /opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/crtbegin.o -L. -L/opt/lib64/../lib64 -L/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0 -L/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/lib64 -L/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/lib -L/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../.. -rpath=/opt/lib64 apps/asn1pars.o apps/ca.o apps/ciphers.o apps/cms.o apps/crl.o apps/crl2p7.o apps/dgst.o apps/dhparam.o apps/dsa.o apps/dsaparam.o apps/ec.o apps/ecparam.o apps/enc.o apps/engine.o apps/errstr.o apps/gendsa.o apps/genpkey.o apps/genrsa.o apps/nseq.o apps/ocsp.o apps/openssl.o apps/passwd.o apps/pkcs12.o apps/pkcs7.o apps/pkcs8.o apps/pkey.o apps/pkeyparam.o apps/pkeyutl.o apps/prime.o apps/rand.o apps/rehash.o apps/req.o apps/rsa.o apps/rsautl.o apps/s_client.o apps/s_server.o apps/s_time.o apps/sess_id.o apps/smime.o apps/speed.o apps/spkac.o apps/srp.o apps/storeutl.o apps/ts.o apps/verify.o apps/version.o apps/x509.o apps/libapps.a -lssl -lcrypto -ldl -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/crtend.o /opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/lib/crtn.o
./libcrypto.so: undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
它似乎在库路径中指示它首先在/opt/lib64中查找,这应该是正常的

产量

nm -g /opt/lib64/libpthread.so | grep pthread_atfork
000000000000edd0 T pthread_atfork@GLIBC_2.2.5
指示该方法应在那里

以下C代码在此系统上创建了相同的链接问题,但在其他系统上编译/链接良好:

// compile with: gcc -pthread mycode.c
#include <stdio.h>
#include <pthread.h>
int main() {
    pthread_t f2_thread, f1_thread;
    void *f2(), *f1(), prepare();
    int i1,i2;
    i1 = 1;
    i2 = 2;
    // int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));
    pthread_create(&f1_thread,NULL,f1,&i1);
    pthread_atfork(&prepare,NULL,NULL);
    pthread_create(&f2_thread,NULL,f2,&i2);
    pthread_join(f1_thread,NULL);
    pthread_join(f2_thread,NULL);
}
void prepare() {
    printf("prepare");
}
void *f1(int *x) {
    int i;
    i = *x;
    sleep(1);
    printf("f1: %d",i);
    pthread_exit(0);
}
void *f2(int *x){
    int i;
    i = *x;
    sleep(1);
    printf("f2: %d",i);
    pthread_exit(0);
}

但这没用。有什么建议吗

-Wl,-rpath=/opt/lib64