ios - 如何为 iOS 交叉编译 clang/llvm?

标签 ios clang llvm cross-compiling

如何交叉编译 clang/llvm for iOS?我需要获取 libclang(我相信是 .a 或 .dylib)才能在我的 iOS 应用程序中通过 C API 使用它。

最佳答案

# 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() 的调用(你会得到 3 次)

make install

关于ios - 如何为 iOS 交叉编译 clang/llvm?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23946851/

相关文章:

ios - iOS中从中央服务器查询大量数据的建议

c++ - 您如何向 clang 添加一个新关键字,一个将被视为主要关键字的关键字?

swift - 包含带有 LLVM 模块映射的 libxml2

llvm - 如何执行llvm代码

c++ - 如何阻止 `/Gm-` 从 CMake 传递给 clang_cl.exe

c++ - 使用 gdb 调试 LLVM 检查器时如何以图形方式查看 CFG

ios - 如何在单击按钮时关闭选项卡栏 Controller 并返回到上一个 View Controller

ios - 在 UIWebView 中限制重定向和抑制广告

ios - CGSize sizeSpace = [ @""sizeWithFont :self. fontHashtag constrainedToSize :rect. size lineBreakMode :self. lineBreakMode];

c - GCC 是否具有检测 use-after-free 错误的功能?