3

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
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

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++
  • 2
    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
11

I think that alternatives are the wrong approach here. More generally, 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/. But, again, I don't think that's a generally good idea. Better to make the choice on a per user — or per-project — basis.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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