Cross compiling ZeroMQ in ARM for use in iPhone iPhone MonoTouch configuration settings

I am trying to use the ZeroMQ library in an iPhone application developed in C # using MonoTouch. I solved almost all the problems, but fell at the last hurdle. I am using ZeroMQ 2.1.10 and the C # CLR binding / shell and developing on Mac OS X 10.6.8. Here is the story:

At first I tried using ZeroMq in a simple Mono C # Console application. I built ZeroMQ with ./configure, then makeand sudo make install, which installs a shared library /usr/local/lib/libzmq.dylib. Linking to ZeroMq C # clrzmq.dllis a wrapper that uses the core functionality of ZeroMq through C Api calls [DllImport].

The test application does not work, and I realized that standard ZeroMQ ./configureproduces 64-bit output, and Mono only 32 bits. Then I restored ZeroMQ with

./configure CFLAGS="-O -arch i386" CXXFLAGS="-O -arch i386" LDFLAGS="-arch i386" --disable-dependency-tracking

A simple C # ZeroMq application worked correctly.

Moving on, I then tried to use ZeroMq from the iPhone application in the iPhone simulator. I found that iPhone only supports statically linked libraries (dynamic libraries are not allowed). This is achieved by changing all C # shell calls to

[DllImport("__Internal", CallingConvention = CallingConvention.Cdecl)]

and including libzmq.adirectly in the MonoTouch project and setting additional arguments mtouch

-cxx -gcc_flags "-L${ProjectDir} -lzmq -force_load ${ProjectDir}/libzmq.a"

to ensure that the ZeroMQ library is included in the iPhone app.

iPhone , zmq_init() socketpair. , , ZeroMQ, MacOS , iPhone SDK.

./configure CFLAGS="-O -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk" CXXFLAGS="-O -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk" LDFLAGS="-arch i386" --disable-dependency-tracking

iPhone Simulator! i386, SDK iPhone. ZeroMQ iPhone Simulator. iPhone.

, iPhone , ARM, iPhone SDK.

( 3 - i386, ARM6 ARM7 3 "" , . ARM ).

** , !! **

- ZeroMQ ARM. , , , , , .

:

./configure CXX=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-g++-4.2
CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
LD=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld CFLAGS="-O -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk"
CXXFLAGS="-O -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk"
--disable-dependency-tracking --host=arm-apple-darwin10
LDFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk" 
AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar 
AS=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/as 
LIBTOOL=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool 
STRIP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip 
RANLIB=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib

, make ZeroMq, , :

ar: libzmq_la-clock.o: No such file or directory

, ./configure .

- ./configure ARM? , , ZeroMQ iPhone.

!

+4
2

, , - , CPP="cpp" CXXCPP="cpp" ./configure, :

./configure CPP="cpp" CXXCPP="cpp" CXX=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-g++-4.2 CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 LD=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld CFLAGS="-O -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk" CXXFLAGS="-O -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk" --disable-dependency-tracking --host=arm-apple-darwin10 LDFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk" AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar AS=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/as LIBTOOL=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool STRIP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip RANLIB=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib

ZeroMQ ARM, iPhone. Buzzed First ( http://itunes.apple.com/gb/app/i-buzzed-first!/id490622820?mt=8)

+5

MonoTouch, , 0MQ iOS (ARM). : C lib iPhone

, , : , lipo. , , , , , , MonoTouch: -)

+2

All Articles