简体   繁体   English

如何为iPhone和iPhone模拟器编译C ++ 0x代码

[英]How to compile C++0x code for the iPhone and iPhone simulator

We have a mathematics/scientific application for protein visualization written in C++ using OpenGL. 我们有一个使用OpenGL用C ++编写的用于蛋白质可视化的数学/科学应用程序。 It was written over the last couple of years and makes extensive use of C++0x features found in GCC 4.4 and later. 它是在过去的几年中编写的,并广泛使用了GCC 4.4和更高版本中的C ++ 0x功能。 (It also compiles with Microsoft Visual C++ 10 on Windows, which supports many C++0x features.) (它还可以与Windows上的Microsoft Visual C ++ 10一起编译,该版本支持许多C ++ 0x功能。)

We want to release an iPhone/iPad version, so we need to port it from Linux/Windows to the iPhone. 我们要发布iPhone / iPad版本,因此我们需要将其从Linux / Windows移植到iPhone。 We've ported similar programs with very little effort--add a handful of Objective C files, and done!--however, due to the C++0x features used here we've got a problem. 我们已经非常轻松地移植了类似的程序-添加了少量的Objective C文件,并且完成了!-但是,由于这里使用的C ++ 0x功能,我们遇到了问题。 Xcode on OS X uses GCC 4.2.1 (from 2007) which predates GCC's C++0x support. OS X上的Xcode使用的GCC 4.2.1(自2007年起)早于GCC的C ++ 0x支持。 It seems a huge step backwards to rewrite all this beautiful C++ 0x code to not use C++0x features, and we really don't want to maintain a backported codebase when the march towards C++0x is clear. 重写所有这些漂亮的C ++ 0x代码以不使用C ++ 0x功能似乎向后退了一大步,当向C ++ 0x迈进时,我们真的不想维护向后移植的代码库。

Is there any way to use GCC 4.5 (or 4.6, from SVN) to target the iPhone and iPhone simulator? 有什么方法可以使用GCC 4.5(或SVN的4.6)针对iPhone和iPhone模拟器? If so, how? 如果是这样,怎么办? Preferably, from within Xcode, since the click-and-run/click-and-debug functionality is very useful. 优选地,从Xcode内部,因为单击并运行/单击并调试功能非常有用。 It'd be great to be able to enter "GCC 4.6" in the "C/C++ Compiler Version" box in Xcode and just have everything work. 能够在Xcode的“ C / C ++编译器版本”框中输入“ GCC 4.6”,并且一切正常即可。

(As an aside, the top-of-the-tree version of Clang--as of just yesterday!--supports some C++0x features, but doesn't yet support lambda expressions so it's probably out for us for now.) (顺便说一句,截止到昨天,Clang的树顶版本支持某些C ++ 0x功能,但尚不支持lambda表达式,因此目前对我们来说不适合。 )

Off the top of my head, I'm going to say there probably isn't a very clean or easy way to do this, until Apple officially supports it. 我要说的是,除非苹果正式支持,否则可能不是很干净或容易的方法。 You probably already know this, but the reason Xcode uses an older version of GCC is that Apple makes extensive modifications to the GNU toolchain, and releases their version under the APSL (which is incompatible with the GPL) . 您可能已经知道这一点,但是Xcode使用较旧版本的GCC的原因是Apple对GNU工具链进行了广泛的修改,并根据APSL(与GPL 不兼容 )发布了它们的版本。 So for the most part, you can consider their version of GCC to be a complete fork. 因此,在大多数情况下,您可以将其GCC版本视为完整的分支。 I ran into this problem when trying to port the Apple version of the toolchain to Linux. 尝试将Apple版本的工具链移植到Linux时遇到了这个问题。 I'd had some limited success, but it is not a small undertaking... 我取得了一些有限的成功,但这可不是一件小事...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM