Getting clang to work on Fedora 15

5

4

I have installed clang via yum:

yum install clang

Unfortunately, even a simple "Hello World!" won't compile because it tries to use the headers of libstdc++4.6 (which I think have c++0x features that clang does not understand). I could not find a libstdc++4.5 package, only for F14 which obviously didn't install.

I even tried installing the 2.9 binaries and also compiled&installed the svn trunk for myself. None of this helped.

I recall having the same problem on ubuntu, but I was able to solve it there by installing libstdc++4.5 headers.

So, how do people use clang on Fedora?

Tamás Szelei

Posted 2011-08-10T13:38:48.930

Reputation: 691

Answers

3

As you know there is a bug and bug in llvm for libstdc++4.6. I just compiled llvm with clang from trunk, according to this instructions

You have to configure include paths, I used this command to configure and compile it on F15 x86_64:

../llvm/configure \
  --enable-optimized \
  --disable-assertions \
  --enable-jit \
  --enable-libffi \
  --enable-shared \
  --with-c-include-dirs=/usr/include:$(find /usr/lib/gcc/*/* \
        -maxdepth 0 -type d)/include \
  --with-cxx-include-32bit-dir=32 \
  --with-cxx-include-root=$(find /usr/include/c++/* -maxdepth 0 -type d) \
  --with-cxx-include-arch=x86_64-redhat-linux

make -j3
sudo make install

Than I was able to compile hello world

#include <iostream>

int main() {
  std::cout << "Hello, World!\n";
  return 0;
}

with

clang -o hello hello.cpp -lstdc++

$ ./hello 
Hello, World!

This docs might be of interest as well.

I suppose there is an alternative to use libc++, but I haven't tried it myself.

Fedora llvm 2.9 binaries won't work because of some mesa dependencies on 2.8.

Hope this helps :)

Paweł Prażak

Posted 2011-08-10T13:38:48.930

Reputation: 277

Yes, the first bug was reported by me :). I also compiled trunk, but I didn't know I had to configure paths. I looked at libc++, but at the moment it looks like it's only for OSX (I think it's distributed with a binary dependency which is OSX-only). I left Fedora for the time being, because I really needed clang (actually clang_complete for vim). Thanks for the insight. – Tamás Szelei – 2011-09-02T11:40:32.347

Glad it solved your question :) Thanks for the update about libc++. – Paweł Prażak – 2011-09-02T11:48:57.367