I\'m trying to install the pyslalib package using python 2.7 on Windows 10 and keep getting the following:
\"collect2.exe: error: ld returned 1 exit status\"
This looks like a problem I had recently. I think there is a problem with the libpython27.a
that comes included with Python (I'm on version 2.7.10). Creating my own libpython27.a
from the python27.dll
as per the instructions found here fixed the problem.
To create Python extensions, you need to link against the Python library. Unfortunately, most Python distributions are provided with
Python22.lib
, a library in Microsoft Visual C++ format. GCC expects a .a file (libpython22.a
to be precise.). Here's how to convertpython22.lib
tolibpython22.a
:
- Download pexport (from here or https://web.archive.org/web/20000829082204/http://starship.python.net/crew/kernr/mingw32/pexports-0.42h.zip).
- Get
Python22.dll
(it should be somewhere on your harddrive).- Run :
pexports python22.dll > python22.def
This will extract all symbols frompython22.dll
and write them intopython22.def
.- Run :
dlltool --dllname python22.dll --def python22.def --output-lib libpython22.a
This will createlibpython22.a
(dlltool
is part of MinGW utilities).- Copy
libpython22.a
toc:\python22\libs\
(in the same directory aspython22.lib
).This trick should work for all Python versions, including future releases of Python. You can also use this trick to convert other libraries.