bin / ld:找不到-l install BigARTM – CentOS v7

我试图在Centos 7上根据这个tutorial安装BigARTM.
但是我收到了这个错误:

/bin/ld: cannot find -lboost_thread-mt
/bin/ld: cannot find -lboost_program_options-mt
/bin/ld: cannot find -lboost_date_time-mt
/bin/ld: cannot find -lboost_filesystem-mt
/bin/ld: cannot find -lboost_iostreams-mt
/bin/ld: cannot find -lboost_system-mt
/bin/ld: cannot find -lboost_chrono-mt
/bin/ld: cannot find -lboost_timer-mt
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libpthread.a(libpthread.o): In function 'sem_open':
(.text+0x6823): warning: the use of 'mktemp' is dangerous, better use 'mkstemp'
collect2: error: ld returned 1 exit status
make[2]: [bin/bigartm] Error 1
make[1]:  [src/bigartm/CMakeFiles/bigartm.dir/all] Error 2
make:  [all] Error 2

我使用yum安装了“开发工具”,我在/usr/lib64中找到了库

rpm -ql boost-devel | grep '_program-\|_date_time-\|_thread-\|_filesystem-\|_iostreams-\|_system-\|_chrono-\|_timer-' 
/usr/lib64/libboost_chrono-mt.so
/usr/lib64/libboost_date_time-mt.so
/usr/lib64/libboost_filesystem-mt.so
/usr/lib64/libboost_iostreams-mt.so
/usr/lib64/libboost_system-mt.so
/usr/lib64/libboost_thread-mt.so
/usr/lib64/libboost_timer-mt.so

我还安装了boost-devel sudo yum install boost-devel

对于libboost_thread lib,我运行了以下命令:

[oshri@analytics build]$rpm -ql boost-devel | grep  libboost_thread
/usr/lib64/libboost_thread-mt.so
/usr/lib64/libboost_thread.a
/usr/lib64/libboost_thread.so
[oshri@analytics build]$ locate thread | grep libboost_thread
/home/oshri/PycharmProjects/playground/libboost_thread-mt.so
/usr/lib/libboost_thread-mt.so
/usr/lib/libboost_thread.a
/usr/lib/libboost_thread.so
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libboost_thread-mt.so
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libboost_thread.a
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libboost_thread.so
/usr/lib64/libboost_thread-mt.so
/usr/lib64/libboost_thread-mt.so.1.53.0
/usr/lib64/libboost_thread.a
/usr/lib64/libboost_thread.so
/usr/lib64/libboost_thread.so.1.59.0
/usr/lib64 (copy)/libboost_thread-mt.so.1.53.0
[oshri@analytics build]$ locate -e thread | grep libboost_thread
/usr/lib/libboost_thread.a
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libboost_thread.a
/usr/lib64/libboost_thread-mt.so
/usr/lib64/libboost_thread-mt.so.1.53.0
/usr/lib64/libboost_thread.a
/usr/lib64/libboost_thread.so
/usr/lib64/libboost_thread.so.1.59.0
/usr/lib64 (copy)/libboost_thread-mt.so.1.53.0

我试过三种方法:

>从/usr/lib64/libboost_\u0026lt;name\u0026gt;-mt.so创建一个链接(使用ln)到/usr/lib64/lboost_\u0026lt;name\u0026gt;-mt.so并将/usr/lib64添加到LD_LIBRARY_PATH.
>创建从/usr/lib64/libboost_\u0026lt;name\u0026gt;-mt.so到/usr/lib/lboost_\u0026lt;name\u0026gt;-mt.so的链接.
>将LIBS = -L /usr/lib64添加到MakeFile.

例如:

[oshri@analytics build]$ls -l /usr/lib/\*program\*
lrwxrwxrwx 4 root root 37 Jan 19 17:38 /usr/lib/lboost_program_options-mt -> libboost_program_options-mt.so.1.53.0
lrwxrwxrwx 4 root root 37 Jan 19 17:38 /usr/lib/lboost_program_options-mt.so -> libboost_program_options-mt.so.1.53.0
[oshri@analytics build]$ls -l /usr/lib64/\*program\*
lrwxrwxrwx 4 root root     37 Jan 19 17:38 /usr/lib64/lboost_program_options-mt.so -> libboost_program_options-mt.so.1.53.0
lrwxrwxrwx 4 root root     37 Jan 19 17:38 /usr/lib64/libboost_program_options-mt.so -> libboost_program_options-mt.so.1.53.0
-rwxr-xr-x 1 root root 468952 Nov  5 20:58 /usr/lib64/libboost_program_options-mt.so.1.53.0
lrwxrwxrwx 1 root root     34 Jan 19 17:38 /usr/lib64/libboost_program_options.so -> libboost_program_options.so.1.53.0
-rwxr-xr-x 1 root root 468944 Nov  5 20:58 /usr/lib64/libboost_program_options.so.1.53.0
[oshri@analytics build]$printenv LD_LIBRARY_PATH
/home/oshri/PycharmProjects/EuroSalesOptimization/runtime/:/usr/lib64/
最佳答案
在没有特别特殊修改的64位Centos7 virt上(过去在Linux上构建时,lib与lib64目录一直存在问题,因此我提到了arch):

# yum -y install git make cmake '@Development Tools' boost-devel
# git clone --branch=stable https://github.com/bigartm/bigartm.git
# cd bigartm
# mkdir build && cd build
# cmake ..
# make
... jeopardy music ...

好的,直到99%才能通过构建失败.通过详细的构建,我们可以发现精确的命令(手动添加一些换行符以避免水平滚动疯狂):

# make VERBOSE=1
...
/usr/bin/c++    -Wall -pthread -fPIC -std=c++11 -O3 -DNDEBUG  
  -static CMakeFiles/bigartm.dir/srcmain.cc.o
  CMakeFiles/bigartm.dir/__/artm/cpp_interface.cc.o  -o ../../bin/bigartm
  -rdynamic ../../lib/libmessages_proto.a ../../lib/libartm-static.a
  ../../lib/libprotobuf.a ../../lib/libgoogle-glog.a -lboost_thread-mt
  -lboost_program_options-mt -lboost_date_time-mt -lboost_filesystem-mt
  -lboost_iostreams-mt -lboost_system-mt -lboost_chrono-mt -lboost_timer-mt
  ../../lib/libmessages_proto.a ../../lib/libinternals_proto.a ../../lib/libgflags.a
  -lpthread 
/usr/bin/ld: cannot find -lboost_thread-mt
/usr/bin/ld: cannot find -lboost_program_options-mt
/usr/bin/ld: cannot find -lboost_date_time-mt
/usr/bin/ld: cannot find -lboost_filesystem-mt
/usr/bin/ld: cannot find -lboost_iostreams-mt
/usr/bin/ld: cannot find -lboost_system-mt
/usr/bin/ld: cannot find -lboost_chrono-mt
/usr/bin/ld: cannot find -lboost_timer-mt
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make[2]: *** [bin/bigartm] Error 1

现在没有找到C库,这是有问题的.一个相关的下一个问题是找不到的精确文件,它找不到,很容易用sysdig解决:

# sysdig -p '%fd.name' proc.name contains ld

而在其他地方重新运行make and lo! static * .a文件是根据sysdig查找的(正如ld已经告诉我们的那样,不存在).所以这里至少有两种可能的解决方案,一方面是不编译静态,另一方面是安装所有各种静态库.让我们使用非静态选项,给出CMakeLists.txt文件中的BUILD_STATIC_LIBS标志.

# cd .. && rm -rf build
# mkdir build && cd build
# cmake -D BUILD_STATIC_LIBS=OFF ..

好吧,没有帮助.好的,让我们手动编辑CMakeLists.txt文件并关闭STATIC构建……

# cd .. && rm -rf build
# vi CMakeLists.txt
...
... make stuff again ...
[ 91%] Built target artm-static
Linking CXX shared library ../../lib/libartm.so
/usr/bin/ld: cannot find -lgflags-static
collect2: error: ld returned 1 exit status

哎呀,看起来这个项目真的非常想要它的静态库.一些

yum whatprovides '*libboost_thread-mt.a'
yum whatprovides '*libc.a'
...
yum -y install glibc-static boost-static

稍后流失

cd ..
git checkout CMakeLists.txt
... build again ...
...
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.

很高兴知道,毕竟其他工作……

# yum -y install git make cmake '@Development Tools' boost-devel glibc-static \
  boost-static python-devel
# git clone --branch=stable https://github.com/bigartm/bigartm.git
# cd bigartm
# mkdir build && cd build
# cmake ..
# make

这类东西应该被移动到一个RPM文件中,所以这些依赖项都可以列出,而不是要求人们使用git克隆和马马虎虎的文档……

转载注明原文:bin / ld:找不到-l install BigARTM – CentOS v7 - 代码日志