Reputation: 3764
I've just compiled latest reps of LLVM, Clang and libc++. Now however I have no idea how to configure the environment to use them. I've added in $PATH the one to compiled binaries and have set the
$D_LIBRARY_PATH=$(llvm-config --libdir)
but anyway when I test run 'clang' with example file it uses some '/usr/bin/ld' linker which I have no idea what is it (as I've uninstalled 'g++' because thought it was the problem (before 'clang' used some linker from it) and I don't have any other C++ compilers).
So now how do I point out the right 'llvm-ld', libc++ include and library paths? I don't want to pass some complex arguments every-time. Perhaps I should set some environment variables.
I'm also using KDevelop with the same effect.
Don't judge me if this sounds stupid but it's my first time with Linux (have always used Windows before). I'm using latest 'OpenSUSE' dist.
Update - here is the output window of CodeLite using clang compiler:
/bin/sh -c 'make -j 2 -e -f Makefile' ----------Building project:[ ClangTest - Debug ]---------- make[1]: Entering directory '/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Workspace/CL_C++_WP/ClangTest' clang++ -c "/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Workspace/CL_C++_WP/ClangTest/main.cpp" -stdlib=libc++ -o ./Debug/main.cpp.o -I. -I/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Build/include/c++/v1/ clang++ -o ./Debug/ClangTest @"ClangTest.txt" -L. -L/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Build/lib/ /usr/bin/ld: cannot find crtbegin.o: No such file or directory /usr/bin/ld: cannot find -lstdc++ /usr/bin/ld: cannot find -lgcc_s /usr/bin/ld: cannot find -lgcc clang-3.7: error: linker command failed with exit code 1 (use -v to see invocation) ClangTest.mk:76: recipe for target 'Debug/ClangTest' failed make[1]: * [Debug/ClangTest] Error 1 make[1]: Leaving directory '/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Workspace/CL_C++_WP/ClangTest' Makefile:4: recipe for target 'All' failed make: * [All] Error 2 0 errors, 0 warnings
Upvotes: 0
Views: 2507
Reputation: 76795
You should be able to run make install
with perhaps an optional DESTDIR=/......
so that it doesn't clobber your system files.
Since you're on OpenSUSE, you might as well use your distribution's build services, and install the SVN version of LLVM-Clang from here. You should be able to find libc++ and LLVM itself as well.
Otherwise, make install DESTDIR=/opt/llvm
should work, and then you can add /opt/llvm/bin/
to PATH
and use libc++ by adding this compile and link option: -stdlib=libc++
. You'll need something like /opt/llvm/lib
in LD_LIBRARY_PATH
as well to find the libc++
so.
This should work pretty much out of the box, but I have only ever used my distribution's packages, not a self-built Clang to do this.
Note that Clang still uses your system linker, ld
, and this is fine. Currently, LLVM does not yet provide a fully functional alternative to this program, but they are working on it.
EDIT: It seems you uninstalled too much: Clang also uses the GCC crtbegin and crtend object files. So just install GCC again along with glibc and its dev package.
Upvotes: 2