简体   繁体   中英

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

I have ac/c++ lib that originally targets win/osx/ubuntu. The lib source is available and I want to compile it for 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.

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). Seems external target in Xcode does not have relative settings?

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.

You can get the iphone sysroot by running:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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