15

I have received an error message when compiled "make"

$ 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

I cannot find any solution for above problem.

GCC version and ld version are like these:

$ 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.

How to fix this compile problem?

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92
Gi Yeon Shin
  • 357
  • 2
  • 7
  • 19
  • Possible duplicate of [Unable to compile: unrecognized relocation](https://stackoverflow.com/questions/46058050/unable-to-compile-unrecognized-relocation) – mattm Apr 12 '19 at 22:05

2 Answers2

14

Relocation 42 on x86-64 is R_X86_64_REX_GOTPCRELX. These relocations are used for optimizations implemented in binutils 2.26 and later.

You will either need to upgrade your binutils version, or re-compile the library you want to use with your current toolchain version.

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92
  • I installed binutils-2.26 by `apt-get install binutils-2.26`, but it did not work yet. `ld --version` commands gives me `GNU ld (GNU Binutils for Ubuntu) 2.24`. So, How can I change the version? The makefile is like this: `CC = g++ -fopenmp` `CFLAGS = -c -02 -Wall -D_I368 -D_UNIX -fPIC -Wno-unused-result -std=c++11 -Wno-sign-compare` – Gi Yeon Shin Oct 11 '18 at 07:12
3

You need upgrade your GCC version. You can do so by running these commands:

yum install centos-release-scl -y
yum install devtoolset-7 -y
scl enable devtoolset-7 bash
Zoe
  • 27,060
  • 21
  • 118
  • 148