Moving R_X86_64_32S against '_Py_NotImplementedStruct' cannot be used when creating a shared object; recompile with -fPIC

I am trying to install the Python dlib library. On some systems (macOS, share Ubuntu 14.04) pip install dlib works fine, but on Ubuntu 14.x this part of our CircleCI environment does not work with the following error.

 Linking CXX shared library dlib.so /usr/bin/ld: /opt/circleci/python/2.7.11/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against '_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC error: cmake build failed! 

What could be wrong?

+5
source share
2 answers

The problem was that Python needed to be compiled with the --enable-shared flag to set dlib for success. Although in some cases the Python system is built using this flag (for example, on Ubuntu), the one we used in the CI environment was installed via pyenv , which does not install it by default.

The solution was to reinstall pyenv -provided Python with the flag set as follows:

PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --force 2.7.11

To use it: machine: python: version: 2.7.11 # Has to match the pyenv-installed version

+10
source

As FYI, my special case was resolved by renaming '/usr/local/lib/libpython2.7.a' to '/usr/local/lib/libpython2.7.a.moved'. According to "yum whatprovides / usr / local / lib / libpython2.7.a", this was not installed as part of any packages installed through yum. Moving this to the side in this case solved my problem.

Here is my initial error message:

  /usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC 

/usr/local/lib/libpython2.7.a: characters with errors added: Bad value collect2: error: ld returned 1 exit status

Given that none of my installed packages took into account .a lib, throwing it aside, there was an option for me.

+1
source

Source: https://habr.com/ru/post/1264994/


All Articles