gcc static静态编译选项提示错误:/usr/lib/ld:cannot find -lc
在学习gcc静态库动态库编译的时候选用静态库编译时出错显示:/usr/lib/ld:cannot find -lc

百度:/usr/lib/ld:cannot find -lc多处给的解决方案为:

然而并不能解决问题,最终定位发现是静态编译的问题。而且不止会出现这种情况:
/usr/lib/ld:cannot find -lc
/usr/lib/ld:cannot find -lgcc_s
/usr/lib/ld:cannot find -lm
等的错误,主要原因在静态编译时需要链接静调库。如上命令:
[xiaohexiansheng@centos6 app]$ gcc -static -I./libs main.c -o app -L./libs -lcrypto -lfunc
如果在编译时去掉-static选项选用动态库编译则不会出现此种情况
[xiaohexiansheng@centos6 app]$ gcc -I./libs main.c -o app -L./libs -lcrypto -lfunc
[xiaohexiansheng@centos6 app]$ ls
app libs main.c
非静态编译时ldd filename,显示如下,这是可执行程序所需的动态库,运行可执行程序时需要的动态库。
[xiaohexiansheng@centos6 app]$ ldd app
linux-gate.so.1 => (0x004ad000)
libcrypto.so => /usr/lib/libcrypto.so (0x03ad9000)
libfunc.so => not found
libc.so.6 => /lib/libc.so.6 (0x0052a000)
libdl.so.2 => /lib/libdl.so.2 (0x0070c000)
libz.so.1 => /lib/libz.so.1 (0x00713000)
/lib/ld-linux.so.2 (0x00508000)
静态编译时需要将所有的.a库链接到可执行文件中,所以需要libc静态库文件,在系统找查找glibc-static提示没有库文件。
#yum install glibc-static安装静态库。
gcc static静态编译选项提示错误:/usr/lib/ld:cannot find -lc的更多相关文章
- gcc static静态编译选项提示错误修正(/usr/lib/ld: cannot find -lc)
用gcc静态编译C程序时显示出: /usr/lib/ld: cannot find -lc /usr/lib/ld: cannot find -lgcc_s /usr/lib/ld: cannot f ...
- make -f dc_debug.mak 提示错误"/usr/bin/ld:can not find -l***"解决办法
在公司不同服务器上"make -f ***"程序的时候,有的服务器可以编译通过,有的却提示"/usr/bin/ld:can not find -l***"的错误 ...
- 编译错误 ----- /usr/bin/ld: cannot find -lc
yum install glibc-static glib-static是Gcc链接时使用到的库.
- 【转】G++ 处理 /usr/bin/ld: cannot find -lc
原文网址:http://blog.sina.com.cn/s/blog_67bbb71101010tto.html 用g++编译C++程序时显示出:/usr/lib/ld: cannot find - ...
- /usr/bin/ld: cannot find -lc
yum install glibc-static [root@test chkrootkit-0.50]# make sensecc -static -o strings-static strings ...
- /usr/bin/ld: cannot find -lc错误原因及解决方法
问题解决 我在执行如下命令的时候,出现了错误. gcc -o main main.c -static -L. –lmylib Linux环境下gcc静态编译/usr/bin/ld: cannot fi ...
- 【转】链接任意目录下库文件(解决错误“/usr/bin/ld: cannot find -lxxx”
netbeans构建项目也出现了同样的问题.猜测是netbeans内部就用的是-l 这种编译方式,所以需要把***.a手动改为lib***.a 原文地址:链接任意目录下库文件(解决错误“/usr/bi ...
- 【解决】/usr/bin/ld: cannot find -lc
现象:运行gcc静态编译程序时报错: /usr/bin/ld: cannot find -lc collect2: ld returned 1 exit statusmake: *** [gcc_dr ...
- android编译错误--/usr/bin/ld: cannot find -lz
编译时出现/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libz.so when se ...
随机推荐
- Linux提权思路
先写个大概 0. dirtycow 不同的dirtycow有不同执行条件. 使用前先对照此表根据内核版本确认是否已经修复 https://github.com/dirtycow/dirtycow.gi ...
- mhn 实际部署记录
新增蜜罐时需要注意,server/collector_v2.py中的DEFAULT_CHANNELS,没有注册这个事件是接收不到新蜜罐的消息的
- bootstrap——集合
1.<nav class="navbar navbar-inverse"> inverse,反色,原导航条为白色,加-inverse后改为黑色 2.data-tog ...
- mysql六:索引原理与慢查询优化
一 介绍 为何要有索引? 一般的应用系统,读写比例在10:1左右,而且插入操作和一般的更新操作很少出现性能问题,在生产环境中,我们遇到最多的,也是最容易出问题的,还是一些复杂的查询操作,因此对查询语句 ...
- 关于preempt_enable 和 preempt_disable 【转】
转自:http://blog.chinaunix.net/uid-8478094-id-2031177.html 关于preempt_enable 和 preempt_disable 允许抢占和禁止抢 ...
- aiohttp/asyncio 小例子和解释
#!/usr/bin/env python # encoding: utf-8 import aiohttp import asyncio import time # 通过async def定义的函数 ...
- request.getRequestDispatcher(url).forward(request, response)
request.getRequestDispatcher().forward(request, response) 意思是将客户端的请求转向到 getRequestDispatcher()方法中参数定 ...
- Appium+python自动化27-android特有的wait_activity【转载】
本篇转自博客:上海-悠悠 前言在启动app的时候,如果直接做下一步点击操作,经常会报错,于是我们会在启动完成的时候加sleep.那么问题来了,这个sleep时间到底设置多少合适呢?设置长了,就浪费时间 ...
- ssl介绍以及双向认证和单向认证原理
SSL安全证书可以自己生成,也可以通过第三方的CA(Certification Authority)认证中心付费申请颁发. SSL安全证书包括: 1. CA证书,也叫根证书或中间级证书.单 ...
- tomcat虚拟主机
直接看配置文件吧,有点基础的都懂 <Host name="localhost" appBase="webapps" unpackWARs="fa ...