ARM为一个MonoTouch的iPhone应用程序配置设置使用

ARM为一个MonoTouch的iPhone应用程序配置设置使用

本文介绍了交叉编译ZeroMQ以ARM为一个MonoTouch的iPhone应用程序配置设置使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用ZeroMQ库使用MonoTouch的在C#开发的iPhone应用程序。我几乎解决了所有的问题,但在最后一关已经下降。我使用ZeroMQ 2.1.10,而C#CLR绑定/包装,并在Mac OS X 10.6.8开发。下面是迄今为止的故事:

I'm attempting to use the ZeroMQ library in an iPhone app developed in C# using MonoTouch. I've solved almost all of the problems, but have fallen at the last hurdle. I'm using ZeroMQ 2.1.10, and the C# CLR binding/wrapper, and developing in Mac OS X 10.6.8. Here's the story so far:

我第一次尝试在一个简单的单声道C#控制台应用程序使用ZeroMq。我建ZeroMQ与 ./配置,那么制作须藤使安装,它安装的共享库 /usr/local/lib/libzmq.dylib 。该ZeroMq C#结合 clrzmq.dll 是通过C API 函数[DllImport] 使用核心ZeroMq功能的包装呼叫。

I first attempted to use ZeroMq in a simple Mono C# Console app. I built ZeroMQ with ./configure, then make and sudo make install, which installs shared library /usr/local/lib/libzmq.dylib. The ZeroMq C# binding clrzmq.dll is a wrapper that uses the 'core' ZeroMq functionality via C Api [DllImport] calls.

测试程序没有工作,我想通了,是该标准ZeroMQ ./配置产生64位输出,和Mono只有32位。然后我重建ZeroMQ以

The test app didn't work, which I figured out to be that the standard ZeroMQ ./configure produces a 64-bit output, and Mono is only 32 bit. I then rebuilt ZeroMQ with

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

然后我简单的C#应用​​程序ZeroMq工作正常。

My simple C# ZeroMq app then worked correctly.

移动的,然后我试图在iPhone模拟器使用ZeroMq从一个iPhone应用程序中。我发现,iPhone只允许静态链接库(没有动态库允许的)。这是通过改变所有的C#包装调用实现

Moving on, I then tried to use ZeroMq from inside an iPhone app in the iPhone simulator. I discovered that the iPhone only allows statically linked libraries (no dynamic libraries allowed). This is achieved by changing all the C# wrapper calls to

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

和包括 libzmq.a 直接在MonoTouch的项目,并设置额外的mTouch参数

and including libzmq.a directly in the MonoTouch project, and setting extra mtouch arguments

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

要确保ZeroMQ库包含在iPhone应用程序。

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

当运行在iPhone模拟器的应用程序,它崩溃了,我追踪到从 zmq_init打了一个电话() socketpair 。我终于追查这已建对我的构建机器的MacOS的头文件和库,而不是对抗iPhone SDK的ZeroMQ库。这是由固定

When running the app in the iPhone simulator, it crashed out, which I traced to a call made from a zmq_init() to socketpair. I finally traced this to the ZeroMQ library having been built against my build machine's MacOS headers and libraries, instead of against the iPhone SDK. This was fixed by

./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模拟器!该模拟器需要建到iPhone模拟器SDK i386的静态库。我现在可以在模拟器只是一个iPhone应用程序中使用ZeroMQ功能。它没有一个真正的iPhone然而工作。

Success in the iPhone Simulator! The simulator requires i386 static libraries built to the iPhone simulator SDK. I now can use ZeroMQ functionality within an iPhone app in the Simulator ONLY. It does not work however on a real iPhone.

这是因为一个真正的iPhone需要已建成为ARM架构库,以及对现实的iPhoneOS SDK。

This is because a real iPhone requires a library that has been built for the ARM architecture, and against the real iPhoneOS SDK.

(有3栋独立的库的一个侧面的问题 - i386的,ARM6和ARM7和所有3组合成可以在任何环境下使用'胖'库我需要能够前搭建ARM我得到这个问题)。

(There is a side-issue of building 3 separate libraries - i386, ARM6, and ARM7, and combining all 3 into 'fat' library that can be used in any environment. I need to be able to build for ARM before I get to this problem).

**最后,我的问题! **

** Finally, my question!! **

最后一步是将交叉编译生成ZeroMQ库ARM。我一直在试图整天想出这个正确的交换机和研究,我可以找到在互联网上所有的例子,但没有似乎有一个可行的解决方案。

The last step is to cross-compile build the ZeroMQ library to ARM. I have been trying all day long to come up with the correct switches for this, and studied all the examples on the internet that I can find, but none seem to have a solution that works.

我得工作最接近的是:

./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

这会产生一个配置其中制作编译ZeroMq code,但未能有很多环节的错误,例如:

This produces a config which make compiles the ZeroMq code, but fails with lots of link errors, e.g.:

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

我试过很多其他的配置,但他们甚至不通过 ./配置正常。

谁能帮我用合适的 ./配置参数列表生产ARM架构的静态库?这是所有我需要ZeroMQ工作的一个真正的iPhone。

Can anyone help me with a suitable ./configure parameter list to produce an ARM architecture static library? This is all I need to get ZeroMQ working on a real iPhone.

和所有帮助不大AP preciated!

And and all help much appreciated!

推荐答案

只是想分享,我发现最终的答案 - 诀窍是添加 CPP =CPPCXXCPP = CPP ./配置语句,赠送:

Just thought I'd share that I found the answer in the end - the trick was to add CPP="cpp" CXXCPP="cpp" to the ./configure statement, giving:

./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应用程序我忽然响起首先用(可在<一href=\"http://itunes.apple.com/gb/app/i-buzzed-first!/id490622820?mt=8\">http://itunes.apple.com/gb/app/i-buzzed-first!/id490622820?mt=8 )

这篇关于交叉编译ZeroMQ以ARM为一个MonoTouch的iPhone应用程序配置设置使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:00