Ubilinux on the Intel Galileo: A Tale of Two Compilers (Part II)

Hello again,
So, from my last post, I explained (in too many words) that I had trouble with gcc on the Ubilinux distro running on an Intel Galileo Gen 1.
Now, I'd read about an alternate...compiler....called Clang. For the experienced readers out there, please don't spit in disgust! Clang isn't just a compiler...its....uh.............a compiler front-end that uses LLVM as its backend..........
For the purposes of this post, think of Clang as a gcc replacement. This is acceptable, and it is actually designed to be a drop-in replacement for gcc in that the invocation and command-line flags are identical between the two. I thought that this would be a good thing to try to circumvent gcc's issues. I was in luck, as I found Clang version 3.5 in the Ubilinux repos (via apt-cache search) and so I went ahead and installed that. You get two compilers...Clang for C (like gcc), and Clang++ for C++ (like g++).
Now, when using Makefiles, it is possible to explicitly specify the C and C++ compilers to be used by invoking make like so:

make CC=clang CXX=clang++

This sets the C compiler to Clang and the C++ compiler to Clang++. Doing this apparently solved my little problem, and I was able to compile the thing with no trouble.
Similarly, if the thing to be compiled uses the CMake build system, then you can acheive the same thing by calling Cmake as follows:


Which then tells CMake to emit Makefiles using Clang as the C compiler and Clang++ as the C++ compiler. Once that's done, you simply need to run 'make' as usual and Bob's your uncle.

So in summary, if you're perchance using Ubilinux on the Intel Galileo, use Clang/Clang++ rather than gcc/g++ for positive results.

*shooting pistols at the sky*

Next post, we'll talk a bit more about the Galileo...till then,
Auf Wiedersehen!


Popular posts from this blog

Enabling SPI1 on the Raspberry Pi B+/Zero/2/3

Bitbanging SPI on the Raspberry Pi (via spi-gpio)

Getting Started with Logic Analyzers and Pulseview