[zeromq-dev] my Arm Story

Moritz Rosenthal mr at m2mgermany.de
Mon Aug 30 15:37:17 CEST 2010


at #zeromq they said it might be of interest to some receivers of this
list, so I'm gonna tell my short story of try, error and success.

How I built 0MQ for my embedded ARM:

First I wanted to try it at my PC. So I used the python install tutorial
[1] and ran into "ImportError: libzmq.so.0: cannot open shared object
file: No such file or directory". No problem - could be solved as
described in [2]. This problem is known since a few months now for
Redhat, but occurs at Ubuntu, too ([3]).

So I simply did this diff manually:
> diff -u a/setup.py b/setup.py
>  --- a/setup.py
>  +++ b/setup.py
>  @@ -49,7 +49,8 @@ else:
>   zmq = Extension(
>      'zmq._zmq',
>      sources = [zmq_source],
>  -    libraries = [libzmq]
>  +    libraries = [libzmq],
>  +    runtime_library_dirs = ['/usr/local/lib'],
> )

Next step was to cross compile the zeromq C libraries for my ARM
architecture. As GNU autotools is used by zeromq that was quite easy:

> ./configure --prefix=<target directory> --host=<arch> 
> make 
> make install

After that I copied the files in <target directory> to the ARM device.

Cross compiling the python part wasn't that easy. I edited setup.cfg and
the change I made to the setup.py to use the libraries from the <target
directory> we used before and ran

> python setup.py -v build

That gave me an idea, of what the script is doing in the background.
Apart from copying a lots of .py-files into the build directory there
were especially two gcc sessions of interest:

> gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
> -Wstrict-prototypes -fPIC
> -I/usr/local/include -I/usr/include/python2.6
> -c zmq/_zmq.c -o build/temp.linux-i686-2.6/zmq/_zmq.o
> gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions
> build/temp.linux-i686-2.6/zmq/_zmq.o
> -L/home/moritz/GEU/git/GEU/usr/local/lib -Wl,-R/usr/local/lib -lzmq
> -o build/lib.linux-i686-2.6/zmq/_zmq.so

Ok - I changed the -I-statements (the header includes used by gcc) and
the gcc command itself to my cross compiler gcc and viola!

Just to put in some interesting stuff for google search: I first only
replaced /usr/local/include but not /usr/include/python2.6. That
compiled well, but I got an

> undefined symbol: PyUnicodeUCS4_DecodeUTF8" 

when trying to import the new module at my arm. I found this posting
[4], where is described, that this error comes from using different
Python header files, when compiling and running a module. So I used the
original header files of my embedded platform for include.

After That all I had to do was rename build/lib.linux-i686-2.6 to
build/lib.linux-arm-2.6 (I didn't really have to, but it seems a better
style, as all binaries inside there are for ARM) and copy it's content
to /usr/lib/python2.6 at my target device.

Thank's for this great library!

Best regards

[1] http://www.zeromq.org/bindings:python
[3] http://mail.scipy.org/pipermail/ipython-dev/2010-March/005900.html
[4] http://lists.openmoko.org/pipermail/devel/2009-January/003948.html
Moritz Rosenthal
Wizardry and magic affairs
m2m Germany GmbH
Rudolf-Diesel-Str. 7 (Industriegebiet Nord)
D-61273 Wehrheim
Phone: +49-6081-58738-65
E-Mail: mm at m2mgermany.de
Internet: www.m2mgermany.de
Fax: +49-6081-58738-69
Sitz der Gesellschaft: 61273 Wehrheim
Handelsregister: Bad Homburg HRB 10714
Vertretungsberechtigte Geschäftsführer:
Michael Nickolai / Jörg Parnitzke

Diese E-Mail enthält möglicherweise vertrauliche und/oder rechtlich
geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder
diese E-Mail irrtümlich erhalten haben, informieren Sie bitte
unverzüglich den Absender.

Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist
nicht gestattet.

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail.
Anyunauthorized copying, disclosure or distribution of the material in
this e-mail is strictly forbidden.

More information about the zeromq-dev mailing list