zoukankan      html  css  js  c++  java
  • jsoncpp relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; ……

    使用jsoncpp 静态库出错解决过程##

    用C++在CLion 中使用 jsoncpp静态库 做解析一个json格式时 出现以下错误:

    relocation R_X86_64_32 against `.rodata' can not be used when making a shared object;  ……
    

    错误显示没写完,最后让加 -fPIC 编译选项。
    解决方法是编译jsoncpp 加上 -fPIC 选项:
    放弃scons编译(当然,scons也应该有解决方法,但我不熟悉),采用cmake编译:
    1.新建编译目录

    mkdir build
    cd build
    

    2.cmake

    cmake -DCMAKE_CXX_FLAGS="-fPIC -Dnullptr=NULL"
    

    3.make & make install

    make -j4
    sudo make install
    

    屏幕上会打印出安装目录,我的是

    -- Install configuration: "Release"
    -- Installing: /usr/local/lib/pkgconfig/jsoncpp.pc
    -- Installing: /usr/local/lib/libjsoncpp.a
    -- Installing: /usr/local/include/json/reader.h
    -- Installing: /usr/local/include/json/version.h
    -- Installing: /usr/local/include/json/features.h
    -- Installing: /usr/local/include/json/autolink.h
    -- Installing: /usr/local/include/json/forwards.h
    -- Installing: /usr/local/include/json/json.h
    -- Installing: /usr/local/include/json/config.h
    -- Installing: /usr/local/include/json/allocator.h
    -- Installing: /usr/local/include/json/value.h
    -- Installing: /usr/local/include/json/assertions.h
    -- Installing: /usr/local/include/json/writer.h

    想加入项目使用而不是作为系统库的话,去相应目录拷贝头文件和静态库就是了。

  • 相关阅读:
    python 发邮件乱码
    膳魔师杯使用注意事项
    了解指针,分分钟的事情 C++筆記--指針
    海淘攻略
    【转】Cocos2dx.3x入门三部曲
    在Windows7上搭建Cocos2d-x 3.2alpha0开发环境
    黑苹果 MAC OS X 10.10.2 安装流程
    Linux 下如何查找木马并处理
    js如何判断访问是来自搜索引擎(蜘蛛人)还是直接访问
    泰*网 Centos 一些命令
  • 原文地址:https://www.cnblogs.com/weiweisuhe/p/6266317.html
Copyright © 2011-2022 走看看