我正在尝试在编译 C++ 程序时静态链接库。
g++ (GCC) 4.8.5 20150623(红帽 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
Run Code Online (Sandbox Code Playgroud)
我发现这篇文章(/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 …Run Code Online (Sandbox Code Playgroud)