Linux Clang?

Sry probably a stupid question, I’m new to linux build on linux, how do i build juce with clang instead of gcc? Ubuntu 18
Is this easy to achieve?

sudo apt-get update
sudo apt-get install clang
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

Then when you make, it’ll use Clang as the compiler.

2 Likes

Instead of exporting you can also directly pass the compiler of choice to your makefile. I always succeeded with simply calling make CXX=clang++ for JUCE-based projects. This should invoke clang++ located in one of the standard binary locations. Furthermore I never had the need to set the C compiler for a JUCE based project – the C++ compiler does it all (correct me if I’m wrong…).

Hint: To speed up your makefile based builds, you might want to pass a flag to the makefile that instructs it to build in parallel, which is reasonable on a modern multicore computer with enough RAM. So you could call make CXX=clang++ -j4 for a parallelization level of 4

Hint to hint: Add the following line to your ~/.bashrc to never worry about typing -j4 again:

alias make='make -j4'

Keep in mind though that you can easily run out of RAM when using high core counts.

2 Likes