cpython编译python工程,编译__init__时报错
__init__.cp36-win_amd64.lib : fatal error LNK1120: 1 unresolved externals
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1120
报错原因是编译器编译import对象时会首先编译__init__对象,没有的话会报错,详细原因可见:python - How to compile __init__.py file using cython on Windows - Stack Overflow
解决方法:
在编译执行文件中加入如下内容:
def get_export_symbols_fixed(self, ext):
pass # return [] also does the job!
# replace wrong version with the fixed:
build_ext.get_export_symbols = get_export_symbols_fixed
即可成功编译