我的构建命令
g ++ -g -m64 -D_FILE_OFFSET_BITS = 64 -fPIC -I./curl-7.60.0/include -I./jsoncpp-src-0.5.0/include/./jsoncpp-src-0.5.0/libs /linux-gcc-4.4.7/libjson_linux-gcc-4.4.7_libmt.so ./ curl-7.60.0 / lib / .libs / libcurl.so.4.5.0 tests.cpp -otests
.so文件存在
-rwxr-XR-X。 1 pswluna developer 529763 2018-05-30 18:48 ./curl-7.60.0/lib/.libs/libcurl.so.4.5.0
但是ldd结果是......(请参阅第3行。)
linux-vdso.so.1 => (0x00007ffd4f5f1000)
./jsoncpp-src-0.5.0/libs/linux-gcc-4.4.7/libjson_linux-gcc-4.4.7_libmt.so (0x00007f833daec000)
libcurl.so.4 => /usr/lib64/libcurl.so.4 (0x0000003b0e600000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000003eb5c00000)
libm.so.6 => /lib64/libm.so.6 (0x0000003eab000000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003eb4c00000)
libc.so.6 => /lib64/libc.so.6 (0x0000003eaac00000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003eab400000)
libidn.so.11 => /lib64/libidn.so.11 (0x0000003ec0c00000)
libldap-2.4.so.2 => /lib64/libldap-2.4.so.2 (0x0000003461200000)
librt.so.1 => /lib64/librt.so.1 (0x0000003eac000000)
libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x0000003088600000)
libkrb5.so.3 => /lib64/libkrb5.so.3 (0x0000003087a00000)
libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x0000003088a00000)
libcom_err.so.2 => /lib64/libcom_err.so.2 (0x0000003eb7000000)
libz.so.1 => /lib64/libz.so.1 (0x0000003eabc00000)
libssl3.so => /usr/lib64/libssl3.so (0x0000003ebb800000)
libsmime3.so => /usr/lib64/libsmime3.so (0x0000003ebbc00000)
libnss3.so => /usr/lib64/libnss3.so (0x0000003eba800000)
libnssutil3.so => /usr/lib64/libnssutil3.so (0x0000003eb9800000)
libplds4.so => /lib64/libplds4.so (0x0000003eb9400000)
libplc4.so => /lib64/libplc4.so (0x0000003eb9c00000)
libnspr4.so => /lib64/libnspr4.so (0x0000003eba000000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003eab800000)
libssh2.so.1 => /usr/lib64/libssh2.so.1 (0x0000003089a00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003eaa800000)
liblber-2.4.so.2 => /lib64/liblber-2.4.so.2 (0x0000003ebe800000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x0000003ead000000)
libsasl2.so.2 => /usr/lib64/libsasl2.so.2 (0x0000003466800000)
libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x0000003088200000)
libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x0000003eb7400000)
libssl.so.10 => /usr/lib64/libssl.so.10 (0x0000003088e00000)
libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x0000003087e00000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x0000003460600000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x0000003086200000)
libfreebl3.so => /lib64/libfreebl3.so (0x000000345f600000)
请帮助我...................
答案 0 :(得分:1)
g ++ -g -m64 -D_FILE_OFFSET_BITS = 64 -fPIC -I./curl-7.60.0/include -I./jsoncpp-src-0.5.0/include/./jsoncpp-src-0.5.0/libs /linux-gcc-4.4.7/libjson_linux-gcc-4.4.7_libmt.so ./curl-7.60.0/lib/.libs/libcurl.so.4.5.0 tests.cpp -otests
此命令 链接您想要的库:./curl-7.60.0/lib/.libs/libcurl.so.4.5.0
,但不安排在运行时使用该库。
这是您想要的命令:
g++ -g -m64 -I./curl-7.60.0/include -I./jsoncpp-src-0.5.0/include/ \
tests.cpp \
-L./jsoncpp-src-0.5.0/libs/linux-gcc-4.4.7 -ljson_linux-gcc-4.4.7_libmt \
-L./curl-7.60.0/lib/.libs -l:libcurl.so.4.5.0 \
-Wl,-rpath=$(pwd)/jsoncpp-src-0.5.0/libs/linux-gcc-4.4.7 \
-Wl,-rpath=$(pwd)/curl-7.60.0/lib/.libs \
-otests
说明:
-rpath
告诉动态加载程序 它应该在运行时搜索库-D_FILE_OFFSET_BITS=64
只有在64位操作系统上构建32位二进制文件时才有意义,但是你没有这样做-fPIC
是完全没必要的。