如何交叉编译clang / llvm的iOS? [英] How to cross-compile clang/llvm for iOS?
问题描述
如何交叉编译clang / llvm for iOS?我需要得到libclang(.a或.dylib我相信)通过C API在我的iOS应用程序中使用它。
$ p> #获取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 ..
#假设Xcode 5.1 LLVM 3.5+还需要-stdlib = libc ++)
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! (否则下一步将失败)
make VERBOSE = 1 -j ...
$ b b
过一会儿你会得到:
/Users/thomas/tmp/llvm-3.4/lib/Support/ Unix / Program.inc:46:10:fatal error:'crt_externs.h'file not found
#include< crt_externs.h> // _NSGetEnviron
^
注释头文件并修改<$ c $
make install
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.
# 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 <crt_externs.h> // _NSGetEnviron
^
Comment the header file and hack the call to _NSGetEnviron()
out (you'll get this three times)
make install
这篇关于如何交叉编译clang / llvm的iOS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!