代码之家  ›  专栏  ›  技术社区  ›  Gi Yeon Shin

无法编译:节文本中存在无法识别的重新定位0x2a

  •  1
  • Gi Yeon Shin  · 技术社区  · 6 年前

    $ make
    g++ -fopenmp  -o lang.test main.o -I../../../include/Lheader -I../../../include -L../../../lib/ -llmi -lblas -lboost_regex -lpthread -lleveldb
    /usr/bin/ld: ../../../lib//liblmi.a(LMInterface.o): unrecognized relocation (0x2a) in section `.text'
    /usr/bin/ld: final link failed: Bad value
    collect2: error: ld returned 1 exit status
    

    我找不到解决上述问题的办法。

    GCC版本和ld版本如下:

    $ gcc --version
    gcc (Ubuntu 5.4.1-2ubuntu1~14.04) 5.4.1 20160904
    Copyright (C) 2015 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    
    $ ld --version
    GNU ld (GNU Binutils for Ubuntu) 2.24
    Copyright 2013 Free Software Foundation, Inc.
    This program is free software; you may redistribute it under the terms of
    the GNU General Public License version 3 or (at your option) a later version.
    This program has absolutely no warranty.
    

    1 回复  |  直到 6 年前
        1
  •  8
  •   Florian Weimer    6 年前

    x86-64上的重新定位42是 R_X86_64_REX_GOTPCRELX . 使用这些重新定位 for optimizations implemented in binutils 2.26 and later

    您需要升级binutils版本,或者重新编译要与当前工具链版本一起使用的库。

        2
  •  2
  •   Zoe - Save the data dump 张群峰    6 年前

    你需要升级你的GCC版本。您可以通过运行以下命令来执行此操作:

    yum install centos-release-scl -y
    yum install devtoolset-7 -y
    scl enable devtoolset-7 bash