Issue #124 resolved

Recreating win64.obj file

Erik Norvelle
created an issue

While trying to compile CFFI under MinGW64, I run into the following issue: the compile fails due to a reference to a non-existent file, named "win64.obj". The error is as follows:

C:\TDM-GCC-64\bin\gcc.exe -DMS_WIN64 -shared -s build\temp.win-amd64-3.3\Release\c\_cffi_backend.o build\temp.win-amd64-3.3\Release\c\libffi_msvc\ffi.o build\temp.win-amd64-3.3\Release\c\libffi_msvc\prep_cif.o build\temp.win-amd64-3.3\Release\c\libffi_msvc\types.o build\temp.win-amd64-3.3\Release\c\_cffi_backend.def -LC:\Anaconda\envs\py33\libs -LC:\Anaconda\envs\py33\PCbuild\amd64 -lpython33 -lmsvcr90 -o build\lib.win-amd64-3.3\_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

The setup.py contains the following comment:

    if sys.maxsize > 2**32:
        # 64-bit: unlist win32.c, and add instead win64.obj.  If the obj
        # happens to get outdated at some point in the future, you need to
        # rebuild it manually from win64.asm.
        _filenames.remove('win32.c')
        extra_link_args.append(os.path.join(COMPILE_LIBFFI, 'win64.obj'))

However, there is no build code for rebuilding this file, and I have not found any references on the web for doing so. Please comment regarding how to fix this issue. Many thanks!

Comments (5)

  1. Erik Norvelle reporter

    I was under the impresion that win64.obj would have to be recompiled. The original source .tar.gz I downloaded was 0.8, and did not have this file. I downloaded it from bitbucket and placed it in c/libffi_msvc. I now get the following result for the linking portion of the build:

    C:\TDM-GCC-64\bin\gcc.exe -DMS_WIN64 -shared -s build\temp.win-amd64-3.3\Release\c\_cffi_backend.o build\temp.win-amd64-3.3\Release\c\libffi_msvc\ffi.o build\temp.win-amd64-3.3\Release\c\libffi_msvc\prep_cif.o build\temp.win-amd64-3.3\Release\c\libffi_msvc\types.o build\temp.win-amd64-3.3\Release\c\_cffi_backend.def -LC:\Anaconda\envs\py33\libs -LC:\Anaconda\envs\py33\PCbuild\amd64 -lpython33 -lmsvcr90 -o build\lib.win-amd64-3.3\_cffi_backend.pyd c/libffi_msvc\win64.obj
    c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\Anaconda\envs\py33\libs/libpython33.a when searching for -lpython33
    build\temp.win-amd64-3.3\Release\c\_cffi_backend.o:_cffi_backend.c:(.text+0x17c): undefined reference to `__imp__Py_NoneStruct'
    build\temp.win-amd64-3.3\Release\c\_cffi_backend.o:_cffi_backend.c:(.text+0x41f): undefined reference to `__imp_PyExc_TypeError'
    build\temp.win-amd64-3.3\Release\c\_cffi_backend.o:_cffi_backend.c:(.text+0x447): undefined reference to `__imp_PyExc_TypeError'
    [... many lines skipped ...]
    build\temp.win-amd64-3.3\Release\c\_cffi_backend.o:_cffi_backend.c:(.text+0x8721): undefined reference to `__imp_PyExc_KeyError'
    build\temp.win-amd64-3.3\Release\c\_cffi_backend.o:_cffi_backend.c:(.text+0x87c7): undefined reference to `__imp_PyExc_KeyError'
    build\temp.win-amd64-3.3\Release\c\_cffi_backend.o:_cffi_backend.c:(.text+0x8857): undefined reference to `__imp_PyExc_ImportError'
    build\temp.win-amd64-3.3\Release\c\_cffi_backend.o:_cffi_backend.c:(.text+0x8afa): undefined reference to `__imp_PyExc_WindowsError'
    c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: build\temp.win-amd64-3.3\Release\c\_cffi_backend.o: bad reloc address 0x28 in section `.data'
    collect2.exe: error: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1
    

    I am baffled by this one... I've always had a very hazy idea of how linking exactly works, so I don't know how to proceed here. Your assistance is greatly appreciated.

  2. Erik Norvelle reporter

    Ok, the above problem is almost certainly caused by the fact that libpython33.a was compiled under MSVC, not MinGW, and there is a compatibility problem. I don't know why this exists, but I have heard that you can't link between libraries created by the MSVC toolchain and the MinGW/GCC toolchain. So, problem "solved", no compiling CFFI under MinGW.

  3. Erik Norvelle reporter

    The problem with compiling under MinGW is almost certainly caused by the fact that libpython33.a was compiled under MSVC, not MinGW, and there is a compatibility problem. I don't know enough about Windows programming to know why this problem exists, but I have heard that you can't link between libraries created by the MSVC toolchain and the MinGW/GCC toolchain. So, problem "solved", no compiling CFFI under MinGW.

  4. Log in to comment