簡體   English   中英

如何為iOS交叉編譯clang / llvm?

[英]How to cross-compile clang/llvm for iOS?

如何為iOS交叉編譯clang / llvm? 我需要在我的iOS應用程序中通過C API使用libclang(我相信.a或.dylib)。

# 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...

過了一會兒你會得到:

/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
         ^

注釋頭文件並破解對_NSGetEnviron()的調用(你會得到這三次)

make install

在Cydia的https://coolstar.org/publicrepo/中的iOSToolChain

iOS上的Clang和LLVM。

我在越獄設備上使用它來編譯iOS的應用程序(ARM 32位或ARM 64位)。

這里有一個很好的參考文章: 從linux命令行編譯IOS程序

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM