2016-09-22 132 views
0

我想建立我自己的python(3.5.2)c擴展取決於zlib。使用Linux上的gcc它完美的工作,但我似乎無法使它在Windows 64位上工作。與python擴展VS2015鏈接器錯誤

我按照說明書安裝zlib的DLL:

Installing ZLIB1.DLL 
==================== 
    Copy ZLIB1.DLL to the SYSTEM or the SYSTEM32 directory. 


Using ZLIB1.DLL with Microsoft Visual C++ 
========================================= 
    1. Install the supplied header files "zlib.h" and "zconf.h" 
     into a directory found in the INCLUDE path list. 

    2. Install the supplied library file "zdll.lib" into a 
     directory found in the LIB path list. 

    3. Add "zdll.lib" to your project. 

我setup.py:

from setuptools import setup, Extension 
from Cython.Build import cythonize 

setup(
    ext_modules=cythonize([Extension("esp", ["bethlib/esp.pyx", "bethlib/c_esp.c", "bethlib/linked_list.c"], libraries=["zdll"], include_dirs=["include"], library_dirs=["lib"])]), 
) 

試圖建立與python setup.py bdist_wheel給出了錯誤:

c_esp.obj : error LNK2001: unresolved external symbol uncompress 
build\lib.win-amd64-3.5\esp.cp35-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals 
error: command 'E:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1120 

uncompress是一個存在於zlib.h中的有效函數。任何解決方案謝謝!

+0

在Windows上,您必須使用與用於構建Python解釋器並推測爲'zlib.dll'(或者使用gcc)相同版本的VS來構建擴展。 – martineau

+0

是的,使用VS2015(visual C++編譯器14.0),並且zlib建議按照使用方法安裝的zlib1.dll –

+0

您確定zlib是x64版本嗎? – refi64

回答

0

我從this website下載了靜態zlib庫,它工作正常。這是一箇舊版本,所以我仍然會欣賞,如果我能夠獲得更新的版本,但現在已經足夠了。