x
Chess - Play & Learn

Chess.com

FREE - In Google Play

FREE - in Win Phone Store

VIEW
Do not do this to install llvm/clang on OSX

Do not do this to install llvm/clang on OSX

lockijazz
Feb 10, 2017, 7:39 PM 1

Installing llvm/clang on OSX 10.12.3 Sierra. Read the following if you want to take advantage of the five hours that I spent in this library.

Install XCode. This lets you use clang++ to compile c++ files.

After installing XCode, run the following in terminal:

 

brew install --with-clang --all-targets --rtti --universal --jit llvm

 

This will take about two hours. Find the llvm folder. In order to compile a c++ file, run the following, except replace ~/Desktop/example.cpp with the path to your file and /usr/local/Cellar/ with the path to your newly installed llvm folder.

 

clang++ ~/Desktop/example.cpp -std=c++11 -L /usr/local/Cellar/llvm/3.9.1/lib -lclang -o ~/Desktop/a.out

 

The -L flag shows clang where to find the llvm library that is necessary if you are trying to use any special clang functions. The -std flag tells the compiler what version of c++ to compile in (in this case, it is c++11). Older compilers do not support many features that are in c++11, which may be why this flag is necessary. I honestly do not know what -lclang does, but it makes the c++ file compile. 

The -o ~/Desktop/a.out tells the compiler where to put the executable. The -o flag tells the compiler to create the file if it does not already exist.

Online Now