[Tutor] Can not install pycrypto on Windows 64bit with cygwin(python27)

Muse Gk goknmuse at gmail.com
Sun Sep 23 09:31:27 CEST 2012


Sorry, it is my mistake. I had installed python-2.7.3 32-bit on my
Windows 7 64-bit machine.

> c:/users/gk/downloads/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../.
> ./x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Python27\libs/libpytho
> n27.a when searching for -lpython27
About this error, I also do lots of researches with Google. I did not
find a solution or there maybe a solution which I just do not how to
do.

So today, I uninstalled python-2.7.3 32-bit and installed python-2.7.3.amd64.exe

lol, kill one error and the other one occurs.
The detail logs about the errors:
---
C:\Users\gk>cd Downloads

C:\Users\gk\Downloads>cd pycrypto-2.6

C:\Users\gk\Downloads\pycrypto-2.6>set LIBRART_PATH=C:\Python27\libs

C:\Users\gk\Downloads\pycrypto-2.6>set PATH=C:\Users\gk\Downloads\mingw64\bin;%P
ATH%

C:\Users\gk\Downloads\pycrypto-2.6>python setup.py build --compiler=mingw32 buil
d_ext -DMS-WIN64
running build
running build_py
running build_ext
running build_configure
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.

building 'Crypto.Random.OSRNG.winrandom' extension
C:\Users\gk\Downloads\mingw64\bin\gcc.exe -mno-cygwin -mdll -Wall -std=c99 -O3 -
fomit-frame-pointer -DMS-WIN64=1 -Isrc/ -IC:\Python27\include -IC:\Python27\PC -
c src/winrand.c -o build\temp.win-amd64-2.7\Release\src\winrand.o
<command-line>:0:3: warning: ISO C99 requires whitespace after the macro name
src/winrand.c:38:0: warning: "_WIN32_WINNT" redefined
c:\users\gk\downloads\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../.
./x86_64-w64-mingw32/include/_mingw.h:244:0: note: this is the location of the p
revious definition
writing build\temp.win-amd64-2.7\Release\src\winrandom.def
C:\Users\gk\Downloads\mingw64\bin\gcc.exe -mno-cygwin -shared -s build\temp.win-
amd64-2.7\Release\src\winrand.o build\temp.win-amd64-2.7\Release\src\winrandom.d
ef -LC:\Python27\libs -LC:\Python27\PCbuild\amd64 -lws2_32 -ladvapi32 -lpython27
 -lmsvcr90 -o build\lib.win-amd64-2.7\Crypto\Random\OSRNG\winrandom.pyd
build\temp.win-amd64-2.7\Release\src\winrand.o:winrand.c:(.text+0xbe): undefined
 reference to `__imp_PyExc_SystemError'
build\temp.win-amd64-2.7\Release\src\winrand.o:winrand.c:(.text+0x163): undefine
d reference to `__imp_PyExc_TypeError'
build\temp.win-amd64-2.7\Release\src\winrand.o:winrand.c:(.text+0x1d0): undefine
d reference to `__imp_PyExc_TypeError'
build\temp.win-amd64-2.7\Release\src\winrand.o:winrand.c:(.text+0x2b4): undefine
d reference to `__imp_PyExc_SystemError'
build\temp.win-amd64-2.7\Release\src\winrand.o:winrand.c:(.text+0x2e8): undefine
d reference to `__imp_PyExc_ValueError'
build\temp.win-amd64-2.7\Release\src\winrand.o:winrand.c:(.text+0x328): undefine
d reference to `__imp_PyExc_TypeError'
build\temp.win-amd64-2.7\Release\src\winrand.o:winrand.c:(.text+0x37c): undefine
d reference to `__imp_PyExc_SystemError'
build\temp.win-amd64-2.7\Release\src\winrand.o:winrand.c:(.text+0x3bd): undefine
d reference to `__imp_PyType_Type'
build\temp.win-amd64-2.7\Release\src\winrand.o:winrand.c:(.text+0x3d2): undefine
d reference to `__imp_Py_InitModule4'
c:/users/gk/downloads/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../.
./x86_64-w64-mingw32/bin/ld.exe: build\temp.win-amd64-2.7\Release\src\winrand.o:
 bad reloc address 0x18 in section `.data'
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
---

Thank you, eryksun(). Is it time to throw in the towel?
I think it is the time.

BTW, I tried to install PyCrypto on my Virtual_Machine which OS is
Fedora_17 64-bit. It only took me no more than 2 minutes to success
perfect installation. lol
I must use Windows at least when I am still at school. Because my
major is Application Chemistry and some chemical related software only
perfect supported on Windows. What's more, people around me rarely use
Linux as their default OS, so am I. Though I am a little familiar with
Linux and fond of Linux, I can only use it with VirtualBox. :(

gk

On Sun, Sep 23, 2012 at 6:38 AM, eryksun <eryksun at gmail.com> wrote:
> On Sat, Sep 22, 2012 at 11:25 AM, Muse Gk <goknmuse at gmail.com> wrote:
>>
>> c:/users/gk/downloads/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../.
>> ./x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Python27\libs/libpytho
>> n27.a when searching for -lpython27
>
> FYI, -lpython27 is for linking to the python27 library. gcc links each
> extension module against the import library "libpython27.a" so at
> runtime the module can access the exported functions and data of the
> shared library "python27.dll".
>
> I just checked the contents of the 64-bit installer,
> python-2.7.3.amd64.msi, and it doesn't include libpython27.a, the
> import lib needed by gcc. 64-bit ActivePython might have it, but
> otherwise I suspect you have a 32-bit Python installation. Are you
> sure you have 64-bit Python installed?
>
> The official 64-bit installer only comes with python27.lib, the import
> library used by MSVC. Apparently differences in the C++ runtime
> between MSVC and gcc make using gcc on Windows officially
> unsupportable. (Yet they continue to include libpython27.a in the
> 32-bit version, which I'd imagine is equally unsupportable.) PyCrypto
> is only C, so this probably isn't an issue. I'm not 100% certain,
> however. All I can say is that in the past when I used Windows I had
> no problems with C extensions built with MinGW for 32-bit Python. I
> mostly stick to Debian Linux these days, so I'm not up to date on the
> pitfalls of 64-bit Windows.
>
> Assuming you've installed the official 64-bit Python, you can try
> creating your own libpython27.a import lib using gendef and dlltool
> (these should be in your MinGW-w64 installation). Start by copying
> C:\Windows\System32\python27.dll to a temp directory. Then run the
> following:
>
>     gendef python27.dll
>
> This creates "python27.def", which lists the DLL's exports. Open this
> file and search for "Py_InitModule4". Make sure the name has _64
> appended to it, i.e. "Py_InitModule4_64". If not, add it. Then run the
> following:
>
>     dlltool --dllname python27.dll --input-def python27.def
> --output-lib libpython27.a
>
> Copy "libpython27.a" to C:\Python27\libs.
>
> As before make sure the library path is set:
>
>     set LIBRARY_PATH=C:\Python27\libs
>
> For good measure, manually define the macro MS_WIN64 in the
> build/install command:
>
>     python setup.py build_ext -DMS_WIN64 install
>
> If this fails, don't hesitate to reply with the errors. I don't mind.
> But it might be time to throw in the towel.


More information about the Tutor mailing list