[cfe-dev] Passing -lstdc++ to the linker when using -stdlib=libc++
Ashok Nalkund
ashoknn at qti.qualcomm.com
Wed Oct 31 16:16:49 PDT 2012
[ Resending: The previous email is awaiting approval since I changed my
email id ]
Hi All,
I'm trying to compile my code with clang (3.1) + libc++ . However I
still need to link in libstdc++ for the exceptions support
(__cxa_begin_catch, __cxa_end_catch etc). So I added -lstdc++ to the end
of the compilation flags, I can see clang gets the flag but when it
actually invokes the linker (/usr/bin/ld) it doesnt pass the lib and so
the linker fails. Here is how clang is invoked:
> clang++ -pthread -std=c++11 -stdlib=libc++ -I/local/mnt/workspace/libcxx/x86_64-centos-linux-clang-libcxx/include -I/local/mnt/workspace/libcxx/x86_64-centos-linux-clang-libcxx/addinclude -fPIC -o tests/area_test tests/area_test.o -L/local/mnt/workspace/libcxx/x86_64-centos-linux-clang-libcxx/lib src/.libs/libhogl.a -lffi -ldl -lrt -L/local/mnt/workspace/boost/lib/x86_64-centos-linux-clang-libcxx -lboost_unit_test_framework -lc++ -lstdc++ -pthread -v
And here is how clang invokes the linker:
> clang version 3.1 (branches/release_31)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> "/usr/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o tests/area_test /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.4.6/crtbegin.o -L/local/mnt/workspace/libcxx/x86_64-centos-linux-clang-libcxx/lib -L/local/mnt/workspace/boost/lib/x86_64-centos-linux-clang-libcxx -L/usr/lib/gcc/x86_64-redhat-linux/4.4.6 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../.. -L/lib -L/usr/lib tests/area_test.o src/.libs/libhogl.a -lffi -ldl -lrt -lboost_unit_test_framework -lc++ -lc++ -lc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-redhat-linux/4.4.6/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../lib64/crtn.o
> tests/area_test.o: In function `boost::unit_test::framework::init(boost::unit_test::test_suite* (*)(int, char**), int, char**)':
> tests/area_test.cc:(.text+0x1583): undefined reference to `__cxa_begin_catch'
Can somebody tell me what I'm doing wrong?
TIA,
ashok
More information about the cfe-dev
mailing list