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?
Thanks in advance.
Xcode also includes the LLVM GCC compiler, which uses the GCC compiler front end for maximum compatibility, and the LLVM back end, which takes advantage of LLVM's advanced code generator. This shows the flexibility of a library-based approach to compiler development.
llvm is keg-only, which means it was not symlinked into /usr/local , because macOS already provides this software and installing another version in parallel can cause all kinds of trouble. Show activity on this post. This way you can call other llvm commands such as llvm-config . A list of llvm can be found here.
All of Apple's operating systems, iOS, macOS, tvOS and watchOS, are built with LLVM technologies. And Xcode, Apple's integrated development environment, supports development in Swift, C, C++, and Objective-C, all of which use and are built with LLVM technologies.
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
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
You might configure the above information in your LLVM derived project with 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 ..
Use XCode to open the project file XXX.xcodeproj and it should build the project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With