动态库问题

时间:2016-08-08 17:10:17

标签: linker g++ shared-libraries linker-errors

我在主机上编译了源文件:

g++ -I./source/utils -m32 ./source/services/library_version_info.cpp -o version_info $DAALROOT/lib/ia32_lin/libdaal_core.so $DAALROOT/lib/ia32_lin/libdaal_thread.so -ltbb -liomp5 -lpthread -ldl

# echo $DAALROOT
# /opt/intel/compilers_and_libraries_2016.3.210/linux/daal/

当我试图在目标机器上调用它时,我得到了这样的错误:

./version_info: error while loading shared libraries: /opt/intel/compilers_and_libraries_2016.3.210/linux/daal/lib/ia32_lin/libdaal_core.so: cannot open shared object file: No such file or directory

# echo $DAALROOT
# /media/sdcard/daalroot/daal
目标计算机上的

$LD_LIBRARY_PATH包含libdaal_core.so的路径,但程序看不到。我该如何解决这个错误?

UPD。主机g ++:5.4.0,目标:4.9.1

UPD2。

ldd version_info
    linux-gate.so.1 (0xb77db000)
    /opt/intel/compilers_and_libraries_2016.3.210/linux/daal/lib/ia32_lin/libdaal_core.so => not found
    /opt/intel/compilers_and_libraries_2016.3.210/linux/daal/lib/ia32_lin/libdaal_thread.so => not found
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x4332e000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x43221000)
    libc.so.6 => /lib/libc.so.6 (0x42e7d000)
    libm.so.6 => /lib/libm.so.6 (0x43003000)
    /lib/ld-linux.so.2 (0x42e50000)

env LD_DEBUG=all ./version_info
       408:
       408: file=/opt/intel/compilers_and_libraries_2016.3.210/linux/daal/lib/ia32_lin/libdaal_core.so [0];  needed by ./version_info [0]
./version_info: error while loading shared libraries: /opt/intel/compilers_and_libraries_2016.3.210/linux/daal/lib/ia32_lin/libdaal_core.so: cannot open shared object file: No such file or directory

echo $LD_LIBRARY_PATH
/media/sdcard/daalroot/daal/lib/ia32_lin:/media/sdcard/daalroot/daal/../tbb/lib/ia32_lin/gcc4.4

1 个答案:

答案 0 :(得分:0)

解决方案:

g++ -I./source/utils -m32 ./source/services/library_version_info.cpp -o version_info -l daal_core -l daal_thread -ltbb -liomp5 -lpthread -ldl