与Xcode一起安装LLVM库 [英] Installing LLVM libraries along with Xcode

查看:91
本文介绍了与Xcode一起安装LLVM库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我刚刚在Mac上安装了Xcode,现在我也想安装LLVM,以便与LLVM本身一起玩一些.当前,编译器(显然)找不到所需的头文件.那么,如果在系统上已经装有Xcode的clang,那么安装LLVM的最佳方法是什么?

So I just installed Xcode on my Mac and now I would like to install LLVM as well in order to play around a bit with LLVM itself. Currently the compiler can (obviously) not find the required header files. So what is the best way to install LLVM if you already have clang, packed with Xcode, on your system?

谢谢.

推荐答案

如果不需要阅读LLVM 实现源代码(例如在lib/tools目录中),则可能只玩libclang,也许使用homebrew就足够了.

If you do not need to read LLVM implementation source code(such as in lib/tools directories) and might only play with libclang, perhaps using homebrew is enough for you.

brew install --with-clang --with-lld --with-python --HEAD llvm

接下来,您需要设置PATHCPLUS_INCLUDE_PATHLD_LIBRARY_PATH.对我来说,

Next you need to set PATH, CPLUS_INCLUDE_PATH and LD_LIBRARY_PATH. For me,

# export PATH=/usr/local/opt/llvm/bin:$PATH
# export CPLUS_INCLUDE_PATH=$(llvm-config --includedir):$CPLUS_INCLUDE_PATH 
# export LD_LIBRARY_PATH=$(llvm-config --libdir):$LD_LIBRARY_PATH 

您可以在XVM的LLVM衍生项目中配置以上信息.

You might configure the above information in your LLVM derived project with XCode.

但是,如果您也对Compiler-RTClang-Tools-Extra感兴趣(请参阅 LLVM下载页面),可能必须将LLVM作为您的XCode项目(如 LLVM系统入门中所述,从该页面下载或通过SVN下载) ).将子项目放在 proper 目录中后,可以使用CMake的XCode生成器,典型用法是:

However if you are also interested in Compiler-RT, Clang-Tools-Extra(see LLVM Download Page) you probably have to make LLVM as your XCode project (download from that page or via SVN as said in Getting Started with the LLVM System). After putting the sub-projects in proper directories, you can use XCode generator from CMake, the typical usage is:

cd YOUR_LLVM_SRC_ROOT
mkdir build
cd build
cmake -G Xcode ..

使用XCode打开项目文件 XXX.xcodeproj ,它应该构建项目.

Use XCode to open the project file XXX.xcodeproj and it should build the project.

这篇关于与Xcode一起安装LLVM库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆