安装强制使用python静态存档而不是共享对象

时间:2015-06-02 16:11:42

标签: python linux cmake

我已经更新了这个问题以及它现在给我的错误,但我无法确定我是在努力还是远离解决方案,因为我对cmake知之甚少!

当试图安装python程序时,我遇到了一个错误,我不确定如何修复。该计划如下:

os.chdir("spenvis_csv")
if not os.path.exists("build"):
    os.mkdir("build")

os.chdir("build")
call("cmake ../", shell=True)
call("make")
os.chdir(loc_dir)
os.chdir("python_utilities")
if not os.path.exists("lib"):
    os.mkdir("lib")

for file_name in os.listdir("spenvis_csv/build/source"):
    if file_name.find("libSpenvis.") !=-1:
        shutil.move("spenvis_csv/build/source/%s" %   

(file_name),"lib/Spenvis.so") 
    os.chdir("..")

错误输出如下:

-- Configuring done
-- Generating done
-- Build files have been written to: /home/smh/Linux/Desktop/gras original/gras-03-03/python/python_utilities/spenvis_csv/build
Scanning dependencies of target Spenvis
[ 33%] Building CXX object source/CMakeFiles/Spenvis.dir/pySpenvisCSV.cc.o
[ 66%] Building CXX object source/CMakeFiles/Spenvis.dir/SpenvisCSV.cc.o
[100%] Building CXX object source/CMakeFiles/Spenvis.dir/SpenvisCSVCollection.cc.o
Linking CXX shared library libSpenvis.so
/usr/bin/ld: /usr/local/lib64/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib64/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [source/libSpenvis.so] Error 1
make[1]: *** [source/CMakeFiles/Spenvis.dir/all] Error 2
make: *** [all] Error 2
啊,我绝对是一个cmake磨砂膏。在源目录中,methinks位于实际的CMakeLists.txt中,如下所示:

# Make sure the compiler can find include files
include_directories (${PYSPENVIS_SOURCE_DIR})

# get boost
set(Boost_USE_STATIC_LIBS   OFF)
#set(Boost_USE_MULTIEADED ON)
find_package(Boost COMPONENTS
                python
             REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})

# get python
include(FindPythonLibs)

set(PythonLibs_USE_STATIC_LIBS   OFF)
find_package(PythonInterp)
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_DIRS})
link_directories(${PYTHON_LIBRARIES})
set_target_properties(${PYTHON_LIBRARIES} PROPERTIES POSITION_INDEPENDENT_CODE ON)


add_library(Spenvis  SHARED pySpenvisCSV.cc SpenvisCSV.cc SpenvisCSVCollection.cc)
TARGET_LINK_LIBRARIES(Spenvis ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})

特别注意最后几行,因为我编辑的那些行指向正确的库。但是,现在我收到了一个新错误:

-- Configuring done
-- Generating done
-- Build files have been written to: /home/smh/Linux/Desktop/gras-03-03/python/python_utilities/spenvis_csv/build
make[2]: *** No rule to make target `/usr/lib64/lib64/libboost_python-mt.so.5', needed by `source/libSpenvis.so'.  Stop.
make[1]: *** [source/CMakeFiles/Spenvis.dir/all] Error 2
make:

现在特别奇怪的是 / usr / lib64 / lib64 / ,我不知道为什么它试图找到该目录,因为它不存在。

我道歉了。我省略了内部缓存条目,但如果它们可以使用,也可以发布它们。

0 个答案:

没有答案