Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set clang++ as the system C++ compiler on Fedora 18. I have installed clang and added it to alternatives but it doesn't appear to be working.

[user@localhost ~]$ alternatives --display c++
c++ - status is auto.
 link currently points to /usr/bin/clang++
/usr/bin/clang++ - priority 1
Current `best' version is /usr/bin/clang++.
[user@localhost ~]$ c++ --version
c++ (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

c++ still appears to be using gcc even though alternatives is configured to use clang++.

type -a c++ output:

[user@localhost ~]$ type -a c++
c++ is /usr/bin/c++
c++ is /bin/c++
share|improve this question
What does type -a c++ say? – jordanm Apr 1 '13 at 19:37
Added type -a c++ output to question. – Jephir Apr 1 '13 at 19:42

I think that alternatives are the wrong approach here. More specifically, I think changing the system default is really the wrong approach. Rather than changing things at that level, I suggest

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

Unless something goes out of its way to break it, this will work with almost all make systems.

If you want this to be the default systemwide, you could put this in the system bash startup scripts in /etc/.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.