gcc报错 can not be used when making a shared object; recompile with -fPIC
使用google protobuf时,出现错误
/usr/bin/ld: /usr/local/lib/libprotobuf.a(message_lite.o): relocation R_X86_64_32S against `_ZTVN6google8protobuf11MessageLiteE' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libprotobuf.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
搜了下,几篇文章如下:
查看整个编译过程,编译过程中看到没有-fPIC选项,如何加进去
看protobuffer的README和INSTALL文档,看到需要添加特殊编译选项,需要在执行configure的时候引入,
于是make clean; make uninstall
./configure CXXFLAGS=-fPIC
查看编译文件,发现已经有了编译选项-fPIC,再次执行编译安装
重新编译程序,这次没有报错,没有出错,问题解决。
另外回答;
原因:
-fPIC 是个神马东东呢?
选项 -fPIC
PIC是Position-Independent-Code的缩写。在计算机系统中,PIC和PIE(Position-IndependentExecutable)是可以在主存中不同位置执行的目标代码。PIC经常被用在共享库中,这样就能将相同的库代码为每个程序映射到一个位置,不用担心覆盖掉其他程序或共享库。
因为so动态库编译的时候加上了 -fPIC,但是连接的 libprotobuf.a文件并不是 -fPIC生成的,所以就报错了。
那就是说连接的 libprotobuf.aa 文件,也需要加上 -fPIC 选项进行编译了。
关于-fPIC:http://blog.sina.com.cn/s/blog_54f82cc201011op1.html
/usr/bin/ld: libs/X86_64/libglog.a(libglog_la-logging.o): relocation R_X86_64_32S against `_ZTVN6google4base6LoggerE' can not be used when making a shared object; recompile with -fPIC libs/X86_64/libglog.a: could not read symbols: Bad value collect2: error: ld returned 1 exit status
只能安装错误提供的方法重现编译libglog.a了,然后,替换了libglog.
CXXFLAGS="-O3 -fPIC" ./configure --prefix=glog-0.3.3/install
参考:http://zrj.me/archives/1066
gcc报错 can not be used when making a shared object; recompile with -fPIC的更多相关文章
- 【Linux】 解决报错: ImportError: libSM.so.6: cannot open shared object file: No such file or directory
centos7 + python3.6.4 我使用 pip3 install opencv-python 安装了opencv-python 之后,在使用 import cv2 报错如下 报错原因 ...
- [one day one question] webpack 打包报错 Cannot assign to read only property 'exports' of object '#<Object>'
问题描述: webpack 打包报错 Cannot assign to read only property 'exports' of object '#<Object>',这怎么破? 解 ...
- suse linux编译安装GCC报错
gcc编译安装过程 1.先安装三个库 gmp mprc mpc 这三个库的源码要到官网去下载 1)安装gmp:首先建立源码同级目录 gmp-build,输入命令,第一次编译不通过,发现缺少一个叫m4的 ...
- linux下安装redis组件报错-gcc报错
报错如图: 1.解决办法 先安装gcc插件.删除redis解压后文件.重新解压
- 编译gcc报错make[3]: Leaving directory `/usr/local/src/gcc-7.4.0/build/gcc' make[2]: *** [all-stage1-gcc] Error 2 处理
因业务需要安装7.4高版本gcc时报错: configure: error: in `/usr/local/src/gcc-7.4.0/build/gcc': configure: error: C+ ...
- Win下GCC报错 error: ‘for’ loop initial declarations are only allowed in C99 mode
##报错## 用GCC编译for循环会出现以下错误 error: 'for' loop initial declarations are only allowed in C99 mode 如图所示: ...
- PyCharm+selenium环境搭建报错:Traceback (most recent call last): TypeError: 'module' object is not callable
环境搭建好后,代码如下: from selenium import webdriverdriver = webdriver.chrome()driver.get("http://www.ba ...
- E: Invalid operation build-depgcc(给字符界面的ubuntu安装gcc 报错
sudo apt-get build-depgccE: Invalid operation build-depgcc 原因是中间少了个空格, 使用如下命令即可. sudo apt-get buil ...
- React报错Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function`
引言 最近在忙毕业设计,博客也很久没更新了,毕业设计使用vue做了一个校园寻物网站,现在开始学Raect,记录一下自己遇到问题,react-redux的connect方法使得组件与Redux建立了联系 ...
随机推荐
- UVA 11542 - Square(高斯消元)
UVA 11542 - Square 题目链接 题意:给定一些数字.保证这些数字质因子不会超过500,求这些数字中选出几个,乘积为全然平方数,问有几种选法 思路:对每一个数字分解成质因子后.发现假设要 ...
- oracle扩展dblink数。
[标记]在进行数据迁移时:出现 Compilation errors for PROCEDURE ZDGAME.GFF_FETCH_MZR_LOG Error: ORA-04052: error oc ...
- js常用总结
常用总结,方便大家学习共享. 1.document.write(""); 输出语句 2.JS中的注释为// 3.传统的HTML文档顺序是:document->html-& ...
- 开源项目源码解析-PhotoView 源码解析
1. 功能介绍 特性(Features): 支持 Pinch 手势自由缩放. 支持双击放大/还原. 支持平滑滚动. 在滑动父控件下能够运行良好.(例如:ViewPager) 支持基于 Matrix 变 ...
- JS控制元素可见(显示)与不可见(隐藏)
方法一: document.getElementById("id").style.visibility="hidden"; document.getElemen ...
- JQuery自定义用户控件方法汇总
首先必用 JQuery.fn.extend方法 使用方法: jQuery.fn.extend({}); 其次 相应控件配置参数设置: jQuery.fn.extend({ uploadPreview: ...
- java高级---->Thread之BlockingQueue的使用
今天我们通过实例来学习一下BlockingQueue的用法.梦想,可以天花乱坠,理想,是我们一步一个脚印踩出来的坎坷道路. BlockingQueue的实例 官方文档上的对于BlockingQueue ...
- Eclipse failed to get the required ADT version number from the sdk
failed to get the required ADT version number from the sdk 解决方法: eclipse 和 android studio 工具不能同时共用同一 ...
- 教主泡嫦娥[有趣的dp状态设计]
P1342 教主泡嫦娥 时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 2012年12月21日下午3点14分35秒,全世界各国的总统以及领导人都已经汇聚在中国 ...
- Codeforces 603E Pastoral Oddities
传送门:http://codeforces.com/problemset/problem/603/E [题目大意] 给出$n$个点,$m$个操作,每个操作加入一条$(u, v)$长度为$l$的边. 对 ...