Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup CLion with portable Clang on ubuntu?

I want to test Clang with CLion in ubuntu. By default Clion detects my gcc installation, but I want to use clang instead of gcc. Moreover, I don't want to install clang via apt-get. I have downloaded llvm, clang (3.6.2) binary from llvm website. I want to use that portable clang binaries.

Here is my system setup:

  • Ubuntu - 14.04
  • gcc - 4.8.4
  • llvm clang - 3.6.2 (portable)
  • CLion - 1.0.4

So how to set up CLion with llvm-clang here?

like image 873
Anindya Chatterjee Avatar asked Feb 09 '23 10:02

Anindya Chatterjee


2 Answers

I got the answer from CLion blog and it works and here it goes.

To provide CMake compiler paths, go to Settings | Build, Execution, Deployment | CMake and pass as CMake options:

-D CMAKE_C_COMPILER=
-D CMAKE_CXX_COMPILER=

In case CMake fails to find some path to clang libs, etc. you can also set there environment variables:

CC=/usr/bin/clang
CXX=/usr/bin/clang++
like image 69
Anindya Chatterjee Avatar answered Feb 11 '23 23:02

Anindya Chatterjee


The FAQ states the following:

At present CLion supports GCC and Clang compilers and is guided by these two to get the libraries and headers paths. In the next releases we are planning to extend the list of compilers available in CLion. To change the compiler, go to the Cache tab in CMake tool window and set the compiler’s path to the CMAKE_CXX_COMPILER variable. Then press Enter and click the Apply Changes and Reload button

like image 29
Arne Avatar answered Feb 11 '23 22:02

Arne