python 3.5 import theano ::hypot error
# win10 , mingw(nuwen,g++ 6.3), python 3.5 ,
描述:
import theano 時生成動態的 mod.cpp ,然後編譯庫的時候報 ::hypot 未定義
原因:
hypot 在"C:\Program Files\Python35\include\pyconfig.h"被重定義了
pyconfig.h
-------------------------------------------
#define hypot _hypot
-------------------------------------------
解決思路:
在import theano 調用 g++ 編譯mod.cpp的時候添加編譯參數 -D_hypot=hypot
實現:
有多種方法可行,例如給 theano 添加配置文件等。
一種實際操作方法:
搜索 theano 文件夾下面含有編譯參數字符串的文件,然後在某個編譯參數後面加上 -D_hypot=hypot
例如:
cc.py "C:\Program Files\Python35\Lib\site-packages\theano\gof\cc.py"
-------------------------------------------
def compile_args(self):
...
"-Wno-write-strings", # generated by our code generator...
"-D_hypot=hypot",
]
-------------------------------------------
cmodule.py "C:\Program Files\Python35\Lib\site-packages\theano\gof\cmodule.py"
-------------------------------------------
def get_gcc_shared_library_arg():
...
return ‘-shared -D_hypot=hypot‘
-------------------------------------------
python 3.5 import theano ::hypot error