Issue #122 invalid

Compiling CFFI under MinGW32 on Windows

Anonymous created an issue


I am attempting to compile CFFI for Win32 using the MinGW toolchain. I have resolved some minor compilation errors, and now everything works find up to the point of linking. This is the output I get:

[Cygwin] $ python build  -c mingw32
running build
running build_py
running build_ext
building '_cffi_backend' extension
C:\MinGW\bin\gcc.exe -DMS_WIN64 -mdll -O -Wall -Ic/libffi_msvc -IC:\Anaconda\envs\py33\include -IC:\Anaconda\envs\py33\include -c c/_cffi_backend.c -o build\\Release\c\_cffi_backend.o
C:\MinGW\bin\gcc.exe -DMS_WIN64 -mdll -O -Wall -Ic/libffi_msvc -IC:\Anaconda\envs\py33\include -IC:\Anaconda\envs\py33\include -c c/libffi_msvc\ffi.c -o build\\Release\c\libffi_msvc\ffi.o
C:\MinGW\bin\gcc.exe -DMS_WIN64 -mdll -O -Wall -Ic/libffi_msvc -IC:\Anaconda\envs\py33\include -IC:\Anaconda\envs\py33\include -c c/libffi_msvc\prep_cif.c -o build\\Release\c\libffi_msvc\prep_cif.o
C:\MinGW\bin\gcc.exe -DMS_WIN64 -mdll -O -Wall -Ic/libffi_msvc -IC:\Anaconda\envs\py33\include -IC:\Anaconda\envs\py33\include -c c/libffi_msvc\types.c -o build\\Release\c\libffi_msvc\types.o
writing build\\Release\c\_cffi_backend.def
C:\MinGW\bin\gcc.exe -DMS_WIN64 -shared -s build\\Release\c\_cffi_backend.o build\\Release\c\libffi_msvc\ffi.o build\\Release\c\libffi_msvc\prep_cif.o build\\Release\c\libffi_msvc\types.o build\\Release\c\_cffi_backend.def -LC:\Anaconda\envs\py33\libs -LC:\Anaconda\envs\py33\PCbuild\amd64 -lpython33 -lmsvcr90 -o build\\_cffi_backend.pyd c/libffi_msvc\win64.obj
gcc: error: c/libffi_msvc\win64.obj: No such file or directory
error: command 'gcc' failed with exit status 1

It looks like the code is almost compiling, so perhaps with a few minor tweaks it would be possible to make CFFI MinGW-compatible. This would be a great help for those of us using Python under non-standard Windows environments.


Comments (5)

  1. Erik Norvelle

    Actually, I should have closed this issue... it turns out that under Windows CFFI has to be compiled with Visual Studio, and cannot be compiled by MinGW because Python itself is not able to link to DLLs created under other toolchains.

    Regarding the 64/32 bit issue, MinGW provides a 64-bit toolchain, which is what I was using, even though the compiler target here says "mingw32"

  2. Log in to comment