Unable to Install pyslalib package using python2.7 / MINGW on Windows 10

后端 未结 1 1664
醉话见心
醉话见心 2020-12-10 22:52

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\"

相关标签:
1条回答
  • 2020-12-10 23:20

    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 convert python22.lib to libpython22.a:

    1. Download pexport (from here or https://web.archive.org/web/20000829082204/http://starship.python.net/crew/kernr/mingw32/pexports-0.42h.zip).
    2. Get Python22.dll (it should be somewhere on your harddrive).
    3. Run : pexports python22.dll > python22.def This will extract all symbols from python22.dll and write them into python22.def.
    4. Run : dlltool --dllname python22.dll --def python22.def --output-lib libpython22.a This will create libpython22.a (dlltool is part of MinGW utilities).
    5. Copy libpython22.a to c:\python22\libs\ (in the same directory as python22.lib).

    This trick should work for all Python versions, including future releases of Python. You can also use this trick to convert other libraries.

    0 讨论(0)
提交回复
热议问题