我正在尝试在编译C ++程序时静态链接库 g ++(GCC)4.8.5 20150623(Red Hat 4.8.5-4)
$ g++ -std=c++11 -I/home/jerry/Desktop/tiny-dnn -m32 -pthread -static train.cpp -o train
/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
我找到了这篇文章 (/usr/bin/ld: cannot find -lc while compiling with makefile)说要安装glibc-static。
bash-4.2# sudo yum install glibc-static
Loaded plugins: langpacks
ol7_UEKR3 | 1.2 kB 00:00:00
ol7_latest | 1.4 kB 00:00:00
No package glibc-static available.
Error: Nothing to do
bash-4.2# yum info glibc-static
Loaded plugins: langpacks
Error: No matching Packages to list
bash-4.2# yum search glibc
Loaded plugins: langpacks
================================================== N/S matched: glibc ===================================================
glibc-common.x86_64 : Common binaries and locale data for glibc
compat-glibc.x86_64 : Compatibility C library
compat-glibc-headers.x86_64 : Header files for development using standard C libraries.
glibc.i686 : The GNU libc libraries
glibc.x86_64 : The GNU libc libraries
glibc-devel.i686 : Object files for development using standard C libraries.
glibc-devel.x86_64 : Object files for development using standard C libraries.
glibc-headers.x86_64 : Header files for development using standard C libraries.
glibc-utils.x86_64 : Development utilities from GNU C library
kdesdk-kmtrace.x86_64 : Assist with malloc debugging using glibc's "mtrace" functionality
kernel-headers.x86_64 : Header files for the Linux kernel for use by glibc
latrace.i686 : LD_AUDIT feature frontend for glibc 2.4+
latrace.x86_64 : LD_AUDIT feature frontend for glibc 2.4+
Name and summary matches only, use "search all" for everything.
如何安装glibc-static?请帮忙。
感谢。
答案 0 :(得分:1)
glibc-static
仅适用于可选渠道。官方不支持可选通道中的RPM包,这就是默认情况下不启用这些通道的原因。
启用可选通道的确切命令取决于产品型号。像
这样的东西subscription-manager repos --enable=rhel-7-server-optional-rpms
可以工作,但细节取决于你的环境(此时它更像是系统管理员而不是编程问题。)
注意: Red Hat不支持静态链接的原因很充分。你真的应该避免它。
答案 1 :(得分:0)
您应该使用glibc-static来编译静态bin