简体   繁体   English

如何在OS X for iOS上交叉编译本机Makefile项目?

[英]How to cross-compile a native makefile project on OS X for ios?

I have ac/c++ lib that originally targets win/osx/ubuntu. 我有一个最初针对win / osx / ubuntu的ac / c ++ lib。 The lib source is available and I want to compile it for ios. lib源可用,我想为ios编译它。

Many of the discussions about this scenario are based on the assumption of an automake configure script and are not very helpful, as the lib is a native makefile project. 关于这种情况的许多讨论都是基于automake配置脚本的假设,并不是很有帮助,因为lib是一个本地makefile项目。

I also tried to add the lib to Xcode 5.1 as an external target, then became clueless of how to specify build settings(Base SDK, target device, etc.) for it(I don't use Xcode often). 我还尝试将lib作为外部目标添加到Xcode 5.1,然后对如何为其指定构建设置(基本SDK,目标设备等)一无所知(我不经常使用Xcode)。 Seems external target in Xcode does not have relative settings? 似乎Xcode中的外部目标没有相对设置?

Any help would be appreciated. 任何帮助,将不胜感激。

To compile C/C++ for iOS, you need to pretty much compile it as you normally would, except you need to use clang / clang++ as the compiler and specify the sysroot, the arch and the iOS version. 要为iOS编译C / C ++,除了需要使用clang / clang++作为编译器并指定sysroot,arch和iOS版本外,您需要像往常一样对其进行编译。

You can get the iphone sysroot by running: 您可以通过运行以下命令获取iphone sysroot:

xcrun --sdk iphoneos --show-sdk-path

So something like this: 所以像这样:

clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk -arch arm64 -arch armv7 -arch armv7s -miphoneos-version-min=7.0 file.cpp

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

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