尼玛真是头疼。
在安装好numpy、scipy、theano后。
在python代码中,敲入:import theano,报错如下:
Problem occurred during compilation with the command line below:
g++ -shared -g -m64 -fPIC -I/usr/local/lib/python2.7/site-packages/numpy/cor
e/include -I/usr/local/include/python2.7 -o /root/.theano/compiledir_Linux-2
.6.18-308.el5-x86_64-with-redhat-5.8-Tikanga-x86_64-2.7.3-64/lazylinker_ext/
lazylinker_ext.so /root/.theano/compiledir_Linux-2.6.18-308.el5-x86_64-with-
redhat-5.8-Tikanga-x86_64-2.7.3-64/lazylinker_ext/mod.cpp -L/usr/local/lib -
lpython2.7
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_
32 against `a local symbol' can not be used when making a shared object; rec
ompile with -fPIC
/usr/local/lib/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "theano/__init__.py", line 55, in <module>
from theano.compile import \
File "theano/compile/__init__.py", line 5, in <module>
from theano.compile.function_module import *
File "theano/compile/function_module.py", line 18, in <module>
import theano.compile.mode
File "theano/compile/mode.py", line 11, in <module>
import theano.gof.vm
File "theano/gof/vm.py", line 486, in <module>
import lazylinker_c
File "theano/gof/lazylinker_c.py", line 89, in <module>
preargs=args)
File "theano/gof/cmodule.py", line 1829, in compile_str
(status, compile_stderr.replace(b('\n'), b('. '))))
Exception: Compilation failed (return status=1): /usr/bin/ld: /usr/local/lib
/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `a local symbol'
can not be used when making a shared object; recompile with -fPIC. /usr/loc
al/lib/libpython2.7.a: could not read symbols: Bad value. collect2: ld retur
ned 1 exit status.
仔细分析错误代码之后,定位原因在于,
python在编译时,libpython2.7.a库中的abstract.o模块的编译过程中,没有加上-fPIC;
按照网上的方法,各种在python编译过程中加上-fPIC参数,都没有解决;
最后仔细看make命令的输出结果,发现abstract.o模块根本就没有经过编译。
继续最终,发现Python的源码路径中Object下,abstract.c和abstract.o都存在,而且这个文件是下载python包是就已经编译好了的(生成了.o文件);
然后删除所有.o文件,然后重新make,在make,就有abstract.o的编译过程了。
尼玛,这个问题整整搞了我10个小时,不知道能不能完全解决。
------------
尼玛,就知道没有那么容易,后来又报另外一个包需要重新编译。
然后我把Python源码目录中所有自带的.o文件删了,然后就ok啦。。。
安装命令如下:
./configure --prefix=/usr/local/ –enable-shared CFLAGS=-fPIC
make
make install
分享到:
相关推荐
boost的linux静态库版本,添加了-fPIC选项,一般的boost静态库没有此选项,动态库在调用的时候会报下面的内容,用了这个库就不会出了(网上教的编译方法都是针对1.55版本的,后面的版本代码都不一样): /usr/bin/...
This test is used to check that -fpic is a default compiler option for the arm-linux-androideabi toolchain.
gcc -c -fPIC add.c sub.c div.c mul.c //-c表示生成.o目标文件,-f后加一些编译选项,PIC表示与位置无关 gcc -shared -o libmymath.so add.o sub.o mul.o div.o//创建共享库mymath,添加add.o,sub.o,...
Python简单神经网络这是一个带有C后端的NeuralNetwork库,非常...尽管它可能是一个python库,但它也可以在C语言中使用(有关使用神经网络解决的XOR问题,请参见MainXOR.c)。汇编这将为python接口编译C后端库gcc -fPIC
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_...
解决Android studio报:No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android的问题
然后您可以激活环境并自动安装所有依赖项,而不会干扰您的标准 python 安装 conda activate metamech pip install -r requirements.txt C将运行 FIRE 算法的部分代码编译到共享库中。根据您的操作系统,请执行以下...
gcc生成动态库。...其中-fPIC选项的作用是:表示编译为位置独立的代码,不用此选项的话编译后的代码是位置相关的, 所以动态载入时是通过代码拷贝的方式来满足不同的调用,而不能达到真正的代码段共享的目的.
如果你安装别的出现libtool没有找到,你就从/usr/bin/libtool cp 一个过来用就好了! 在64位下编译GD 如果/usr/bin/ld: /usr/local/lib/libz.a(compress.o): relocation R_X86_64_32 against `a local symbol' can ...
这个库可以解决如下编译错误问题! /usr/bin/ld: libboost_python.a(from_python.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC ...
SPECCPU 2017 整型测试程序的命令行,从代码中抠出,用于单独运行benchmark进行实验
开源的openssl-1.0.2k源代码,编译方式请搜索参考百度文档
Linux环境下的软件安装,并不是一件容易的事情;如果通过源代码编译后...但万变不离其中,对基础知识的扎实掌握,安装各种软件的问题就迎刃而解了。Configure脚本配置工具就是基础之一,它是autoconf的工具的基本应用。
该工程使用python脚本调用c代码实现wav音频...1.gcc编译生成动态库speed_change.dll:gcc -o speed_change.dll -shared -fPIC runsonic.c sonic.c sonic.h。 2.使用python代码speedup.py调用speed_change.dll进行变速。
GCC静态库和共享库的生成及调用 GCC静态库和共享库的生成及调用
webrtc-audio-processing-1.0例子,含代码和音频测试文件
详细介绍mmap 内核态映射到用户态的使用
metaRTC3.0的android/linxu/windows的 第三方类库的二进制文件 安卓系统包含两个ABI:arm64-v8a和x86_64 windows系统为msvc2019 64位 linux系统为64位
MySQL-python-1.2.1.tar.gz $ cd MySQL-python-1.2.1 $ # edit site.cfg if necessary $ python setup.py build $ sudo python setup.py install # or su first python import MySQLdb 报错: ImportError: dlopen(/...
安装 构建模块需要以下内容: Python2 C 头文件 ( python-dev ) C 编译器和链接器,以及 Make ( build-essential ) ( swig ) EMD 源代码和接口定义(本存储库中的emd.h 、 emd.c和emd.i ) 前三个条目后面括号中的...