On Nov 7, 7:19 pm, Jason <jason.hee...@gmail.com> wrote: > My situation is this: I have a Diamond Systems single-board computer > with a > matching GPIO board. DS have a library for controlling the GPIO > board... but > it's a static library (libdscud-6.02.a) with an accompanying header > (dscud.h). > I'd like to create a Python extension to use the device. > > The architecture of the SBC is 486, and it runs Debian Squeeze/Grip. > While it > is possible to develop on it directly, I'd rather use my desktop > machine > (Debian Squeeze, amd64). > > If I write a simple C program to control the device, I'd include the > header > file and cross-compile it like so: > > gcc -m32 -march=i386 -lpthread -I/usr/local/dscud-6.02 -o dio > dio.c \ > /usr/local/dscud-6.02/libdscud-6.02.a > > To get myself started with the Python extension, I've basically taken > the > "noddy" demo[1] and thrown in a function call from the DSC library > just to see > if I can get something to build. > > My distutils setup.py looks like: > > ---- > from distutils.core import setup, Extension > > module1 = Extension('noddy', > sources = ['src/noddy.c'], > libraries = ['pthread'], > include_dirs = ['/usr/local/dscud-6.02'], > extra_objects = ['/usr/local/dscud-6.02/libdscud-6.02.a'], > extra_compile_args = ['-m32', '-march=i386']) > > setup(name = 'Noddy', version = '1.0', description = 'This is a demo > package', > ext_modules = [module1]) > ---- > > This works fine on the target machine with "python setup.py build", > but when I > try it on my desktop machine, I get: > > ---- > $ python setup.py build > running build > running build_ext > building 'noddy' extension > creating build > creating build/temp.linux-x86_64-2.6 > creating build/temp.linux-x86_64-2.6/src > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall > -Wstrict-prototypes -fPIC -I/usr/local/dscud-6.02 -I/usr/include/ > python2.6 -c > src/noddy.c -o build/temp.linux-x86_64-2.6/src/noddy.o -m32 - > march=i386 > In file included from /usr/include/python2.6/Python.h:58, > from src/noddy.c:1: > /usr/include/python2.6/pyport.h:694:2: error: #error "LONG_BIT > definition > appears wrong for platform (bad gcc/glibc config?)." > error: command 'gcc' failed with exit status 1 > > ---- > > So is it possible to get distutils to cross compile something like > this, and > if so, what am I missing? Or am I using the wrong tool for the job? > > Target python ver. is 2.6. GCC is 4.4.5. > > Cheers, > Jason > > [1]http://docs.python.org/extending/newtypes.html
Cross compilation might be one solution to Python access. The SIMPL toolkit (http://www.icanprogram.com/simpl; http://www.icanprogram.com/06py/lesson1/lesson1.html) might be easier. If you ultimately want to communicate from a 64bit to a 32bit system, you'll probably want to use a text based tokenized messaging strategy as opposed to the binary one in these examples. bob -- http://mail.python.org/mailman/listinfo/python-list