bin/ld: 找不到 -l安装 BigARTM - CentOS v7

bin/ld: 找不到 -l安装 BigARTM - CentOS v7

我正在尝试根据此安装 BigARTM教程在 Centos 7 上。但我收到此错误:

/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

我安装了'Development Tools'using 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-develsudo yum install boost-devel

对于libboost_threadlib 我运行了以下命令:

[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

我尝试了三种方法:

  1. 创建链接(使用ln) from /usr/lib64/libboost_<name>-mt.soto/usr/lib64/lboost_<name>-mt.so并添加/usr/lib64to LD_LIBRARY_PATH
  2. 创建从/usr/lib64/libboost_<name>-mt.so到 的链接
    /usr/lib/lboost_<name>-mt.so
  3. 添加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/

答案1

在没有特别修改的 64 位 Centos7 virt 上(过去在 Linux 上构建时目录一直是有问题的,因此我提到了 arch)liblib64

# 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 库,现在这是有问题的。下一个相关问题是ld它无法找到哪些精确文件正在寻找,可以轻松解决sysdig

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

在其他地方重新运行make,瞧!正在根据(正如已经告诉我们的那样,静态文件不存在)*.a查找静态文件。因此,这里至少有两种可能的解决方案,一方面不编译静态,另一方面安装所有这些各种静态库。让我们使用非静态选项,因为文件中的标志很方便。sysdigldBUILD_STATIC_LIBSCMakeLists.txt

# 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 克隆和马马虎虎的文档来搞乱...

相关内容