[cfe-dev] Clang 3.1: Can't link Hello World-program program on Linux

Alexander Korsunsky fat.lobyte9 at gmail.com
Thu Mar 1 02:03:56 PST 2012


Hello,
I am currently trying to build a Hello World-program on Fedora 16 using
Clang from Subversion:

clang version 3.1 (trunk 151711)
Target: x86_64-unknown-linux-gnu
Thread model: posix

When building without "--stdlib=libc++", I run into compile-time-errors
in the GNU implementation of the IOstream library.
So I built libc++ (with the above compiler), using the workaround
suggested in this thread:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-February/019910.html

With the "--stdlib=libc++" option, the linking of the program fails,
asking for some symbols from the CXXABI:

$ clang++ --stdlib=libc++ -o helloworld helloworld.cpp
/usr/bin/ld: /tmp/helloworld-Jxd2ZV.o: undefined reference to symbol
'__cxa_begin_catch@@CXXABI_1.3'
/usr/bin/ld: note: '__cxa_begin_catch@@CXXABI_1.3' is defined in DSO
/usr/lib64/libstdc++.so.6 so try adding it to the linker command line
/usr/lib64/libstdc++.so.6: could not read symbols: Invalid operation
clang-3: error: linker command failed with exit code 1 (use -v to see
invocation)

What did I do wrong? Is Clang or libcxx misconfigured, or is this a
compiler bug? How could I fix or work around the issue?

I'd love to use Clang for some testing of C++11, since it gained a lot
support recently (thanks a lot by the way! Kudos to Clang hackers!).

Alexander




More information about the cfe-dev mailing list