2017-03-03 99 views
5

我正在嘗試安裝dlib Python庫。在某些系統上(macOS,股票Ubuntu 14.04)pip install dlib工作正常,但在我們的CircleCI環境中的Ubuntu 14.x中,它失敗並出現以下錯誤。在創建共享對象時,無法使用針對'_Py_NotImplementedStruct'的重定位R_X86_64_32S;用-fPIC重新編譯

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! 

什麼可能是錯的?

回答

10

問題是Python需要用--enable-shared標誌進行編譯,以便dlib安裝成功。儘管在某些情況下,系統Python是使用此標誌構建的(例如在Ubuntu上),但我們在CI環境中使用的系統是通過pyenv進行安裝的,默認情況下它不會將其設置。

的解決方案是重新安裝pyenv -provided用Pyt​​hon這樣設置標誌:

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

爲了確保這一點被使用: machine: python: version: 2.7.11 # Has to match the pyenv-installed version

1

作爲一個僅供參考,我的具體情況是通過將'/usr/local/lib/libpython2.7.a'重命名爲'/usr/local/lib/libpython2.7.a.moved'來解決。根據'yum whatprovides /usr/local/lib/libpython2.7.a'的輸出,這並不是作爲通過yum安裝的任何軟件包的一部分安裝的。在這種情況下解決這個問題,解決了我的問題。

這是我原來的錯誤消息:

/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:錯誤添加符號:壞值 collect2:錯誤:LD返回1退出狀態

鑑於我所安裝的軟件包都不包含.a庫文件,因此將它移到一邊是我的一個選擇。

相關問題