How to cross-compile clang/llvm for iOS?

匿名 (未验证) 提交于 2019-12-03 01:48:02

问题:

How to cross-compile clang/llvm for iOS? I need to get libclang (.a or .dylib i believe) to use it via C API in my iOS app.

回答1:

# Get LLVM/Clang  mkdir llvm curl -O http://llvm.org/releases/3.4/llvm-3.4.src.tar.gz tar xzfv llvm-3.4.src.tar.gz cd llvm-3.4/tools/ curl -O http://llvm.org/releases/3.4/clang-3.4.src.tar.gz tar xzfv clang-3.4.src.tar.gz mv clang-3.4 clang cd ..  # Assuming Xcode 5.1 (LLVM 3.5+ requires -stdlib=libc++ as well)  export CC="clang -arch armv7 -mios-version-min=5.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk" export CXX="clang++ -arch armv7 -mios-version-min=5.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk"  mkdir build cd build  ../configure \   --prefix=/Users/thomas/tmp/llvm-ios \   --host=arm-apple-darwin11 \   --enable-optimized \   --disable-assertions  unset CC CXX # important! (Otherwise the next step will fail)  make VERBOSE=1 -j... 

After a while you will get:

/Users/thomas/tmp/llvm-3.4/lib/Support/Unix/Program.inc:46:10: fatal error: 'crt_externs.h' file not found #include  // _NSGetEnviron          ^ 

Comment the header file and hack the call to _NSGetEnviron() out (you'll get this three times)

make install 


回答2:

iOSToolChain in the https://coolstar.org/publicrepo/ in Cydia.

Clang and LLVM on iOS.

I used it on a jailbroken device to compile C apps for iOS (ARM 32 bit or ARM 64 bit).

There is a good reference post here: Compile IOS program from linux commandline



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!