Reputation: 11
I have a c/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.
Upvotes: 1
Views: 1256
Reputation: 97
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
Upvotes: 1