libftdi Archives

Subject: Re: Building 64bit Python binding under Windows

From: Xiaofan Chen <xiaofanc@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 20 Feb 2013 10:09:24 +0800
On Mon, Feb 18, 2013 at 12:10 PM, Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
> On Sat, Feb 16, 2013 at 10:32 PM, Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
>> I just tried to build 64bit Python 2.7.3 binding under
>> Windows Vistaq 64bit. Somehow it failed. Other
>> things are fine (not building Boost binding, the
>> unit test program and ftdi_eeprom).
>>
>> What could be the problem?
>>
>> Scanning dependencies of target _ftdi1
>> [ 47%] Building C object 
>> bindings/CMakeFiles/_ftdi1.dir/ftdi1PYTHON_wrap.c.obj
>> Linking C shared module _ftdi1.pyd
>> CMakeFiles/_ftdi1.dir/objects.a(ftdi1PYTHON_wrap.c.obj): In function 
>> `SWIG_Pytho
>> n_ErrorType':
>> c:/work/libftdi/libftdi1-1.0/mingw64_rvb/bindings/ftdi1PYTHON_wrap.c:989: 
>> undefi
>> ned reference to `__imp_PyExc_RuntimeError'
>
> Google seems to point out the main reason. Python.org binaries does not
> provide the libpythonxx.a (MinGW import library) for 64bit Python even
> though it does that for 32bit Python.
>
> Found this link.
> http://stackoverflow.com/questions/11182765/how-can-i-build-my-c-extensions-with-mingw-w64-in-python
>
> Firstly tried Python 2.7 64bit, the building process is fine but
> it does not be able to load the module.
> c:\work\libftdi\libftdi1-1.0\examples\python>python
> Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on 
> win
> 32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import ftdi1 as ftdi
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "C:\python27\lib\site-packages\ftdi1.py", line 30, in <module>
>     _ftdi1 = swig_import_helper()
>   File "C:\python27\lib\site-packages\ftdi1.py", line 26, in 
> swig_import_helper
>     _mod = imp.load_module('_ftdi1', fp, pathname, description)
> ImportError: DLL load failed: The specified procedure could not be found.

For Python 2.7, the answer is not to mess with the def file like the
Stackoverflow link, rather the right answer is to add -DMS_WIN64
to the CMake flags.

Ref: http://permalink.gmane.org/gmane.comp.gnu.mingw.w64.general/6858
++++++++++++++++
>From Ruben.
" add -DMS_WIN64
  to your module compilation. This will fix all of your problems (it fixed
  mine when building gdb with Python support).

 Note that no manual editing of def files should be done"
++++++++++++++++

After that,the module can be loaded. I need to carry out some
tests with real device to see if that works.

> Then I tried Python 3.3 and it seems to go fine when building the
> Python bindings. But then it failed to load the module and says
> that "Python.exe has stopped working".

I will try again as well using -DMS_WIN64.


-- 
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread