views:

79

answers:

1

hey,

I have a firmware for an USB module I can already control by visual C. Now I want to port this to python. for this I need the octopus library which is written in c. I found a file called octopus_wrap which was created by SWIG!

then I found a makefile which says:

python2.5: swig -python -outdir ./ ../octopus.i gcc -fPIC -c ../../liboctopus/src/octopus.c gcc -fPIC -c ../octopus_wrap.c -I /usr/include/python2.5 gcc -fPIC -shared octopus_wrap.o octopus.o /usr/lib/libusb.so -o _octopus.so

python2.4: swig -python -outdir ./ ../octopus.i gcc -fPIC -c ../../liboctopus/src/octopus.c gcc -fPIC -c ../octopus_wrap.c -I /usr/include/python2.4 gcc -fPIC -shared octopus_wrap.o octopus.o /usr/lib/libusb.so -o _octopus.so

win: gcc -fPIC -c ../../liboctopus/src/octopus.c -I /c/Programme/libusb-win32-device-bin-0.1.10.1/include gcc -fPIC -c octopus_wrap.c -I /c/Python25/libs -lpython25 -I/c/Python25/include -I /c/Programme/libusb-win32-device-bin-0.1.10.1/include gcc -fPIC -shared *.o -o _octopus.pyd -L/c/Python25/libs -lpython25 -lusb -L/c/Programme/libusb-win32-device-bin-0.1.10.1/lib/gcc

clean: rm -f octopus* _octopus*

install_python2.4: cp _octopus.so /usr/local/lib/python2.4/site-packages/ cp octopus.py /usr/local/lib/python2.4/site-packages/

install_python2.5: cp _octopus.so /usr/local/lib/python2.5/site-packages/ cp octopus.py /usr/local/lib/python2.5/site-packages/

I dont know how to handle this but as far as I can see octopus.py and _octopus.so are the resulting output files which are relevant to python right?

luckily someone already did that and so I put those 2 files to my "python26/lib" folder (hope it doesnt matter if it´s python 2.5 or 2.6?!)

So when working with the USB device the octopus.py is the library to work with! Importing this file makes several problems:

>>> 
Traceback (most recent call last):
File "C:\Users\ameise\My Dropbox\µC\AVR\OCTOPUS\octopususb-0.5\demos\python    \blink_status.py", line 8, in <module>
from  octopus import *
File "C:\Python26\lib\octopus.py", line 7, in <module>
import _octopus
ImportError: DLL load failed: module not found.

and here´s the related line 7 :

import _octopus

So there´s a problem considering the .so file! What could be my next step?

I know that´s a lot of confusing stuff but I hope anyone of you could bring some light in my mind!

thy in advance

A: 

You should link and compile for the python2.6 -lpython26. Also the file extension for windows is .pyd no .so

fabrizioM
can I recompile this with visual studio?
wanderameise
sure you can, after the swig generates the .c file, you can create a simple setup.py to compile itsee http://docs.python.org/distutils/setupscript.html
fabrizioM
wow slowly for a rookie! what excatly to do step by step.and how to combine swig and VC?can u explain a little more so I can follow?
wanderameise