Chaitanya Bapat
Chaitanya Bapat

Reputation: 4029

relocation R_X86_64_PC32 against symbol `_PyRuntime' can not be used when making a shared object; recompile with -fPIC

Getting following link error while building a library in Python3.7 on 64bit machine.

 /usr/bin/ld: /usr/local/lib/libpython3.7m.a(ceval.o): relocation R_X86_64_PC32 against symbol `_PyRuntime' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: final link failed: Bad value
    collect2: error: ld returned 1 exit status

On that same machine, if I install a miniconda https://docs.conda.io/en/latest/miniconda.html [Py 3.8 for 64bit], the library installs fine in that conda environment without any error.

I tried buildingin Py3.7 by adding

export CFLAGS="$CFLAGS -fPIC"

However, the error persists for python3.7

Upvotes: 2

Views: 4132

Answers (1)

Chaitanya Bapat
Chaitanya Bapat

Reputation: 4029

Option 1

Build/Compile Python using --enable-shared

Option 2

Error suggests using -fPIC So one can choose

CFLAGS=-fPIC

in the make install or [equivalent build step]

Both should work.

Upvotes: 6

Related Questions