You can build it yourself. configure or cmake based builds works out of the box..
I do have two modifications to the source code, one pertaining to clang unable to find
mingw header files (4.7.2, 4.7.3 etc) and one about calling convention if you happen upon
some problems..
Interestingly I'd come to report nullptr causing problems with clang because definition in
prep.h does not consider clang.
#if !(__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined __GXX_EXPERIMENTAL_CXX0X__)
// it is a const object...
const class nullptr_t
{
public:
// constructor
nullptr_t() {}
// convertible to any type of null non-member pointer...
template<typename T> operator T* () const{ return (T*)0; }
// or any type of null member pointer...
template<typename C, typename T> operator T C::* () const { return (T C::*)0; }
// support operator overloading (== and !=)
template<typename T> bool equals(T const& rhs) const { return rhs == 0; }
private:
// can't take address of nullptr
void operator&() const;
// can't copyable
nullptr_t(const nullptr_t&);
const nullptr_t& operator=(const nullptr_t&);
} nullptr_;
#define nullptr nullptr_
#endif
it needs also something like
#if !(__has_feature(cxx_nullptr))
Clang does not use something like GXX_EXPERIMENTAL_CXX0X or version numbers but instead opts for
__has_feature macro to query if certain language features are enabled.
http://clang.llvm.org/docs/LanguageExtensions.html#checking_upcoming_features
Building on Linux is quite straight forward:
http://codelite.org/Developers/HomePage#toc2 (http://codelite.org/Developers/HomePage#toc2)
Once you have completed the above steps - just run
To build their libc++ (this is what I am using to build it on my linux box):
svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
cd libcxx
mkdir build-release
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
make -j8
sudo make install
You can get more details here:
http://libcxx.llvm.org/ (http://libcxx.llvm.org/)
Eran
on your instructions for building libcxx :
mkdir build-release
cd build-release <======================
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
I forgot to mention that you will need libc++abi as well.., building it on linux does not work "out-of-the-box" but requires a small tweak:
First, checkout libcxxabi:
svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi
Next:
Now you need to add some include paths... otherwise it will not compile:
run:
g++ -v -x c++ /dev/null -fsyntax-only
Locate the output line which is similar to this:
/usr/lib/gcc/x86_64-linux-gnu/4.7/include
Adjust CXX environment variable so it will be something similar to this:
export CXX='clang++ -I/usr/local/include/c++/v1 -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include'
and compile libcxxabi by simply typing:
once the compilation is done, you should have a new lib: libc++abi.so.1.0
I could not find a simple way of installing so I copied it manually to /usr/local/lib and created 2 symlinks:
ln -sf /usr/local/lib/libc++abi.so.1.0 /usr/local/lib/libc++abi.so
ln -sf /usr/local/lib/libc++abi.so.1.0 /usr/local/lib/libc++abi.so.1
Now compiling with clang++/libc++ should be like this:
clang++ -stdlib=libc++ -c test.cpp -I/usr/local/include/c++/v1
clang++ -stdlib=libc++ test.o -o TestMe -lc++ -lc++abi -I/usr/local/include/c++/v1/
Eran
Thanks Eran, but not yet ok for me :
error while loading shared libraries: libc++abi.so.1: cannot open shared object file: No such file or directory
Did you remember to add /usr/local/lib to LD_LIBRARY_PATH?
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
In addition, note that you should create 2 symlinks
ln -sf /usr/local/lib/libc++abi.so.1.0 /usr/local/lib/libc++abi.so
ln -sf /usr/local/lib/libc++abi.so.1.0 /usr/local/lib/libc++abi.so.1
Eran
yes, it is not in my PATH ;-) /usr/local/bin is
In a console I did :
killerbot@XIII:~/Projects/TryOUt/ClangC11/Deliv/Debug> ./ClangC11
./ClangC11: error while loading shared libraries: libc++abi.so.1: cannot open shared object file: No such file or directory
killerbot@XIII:~/Projects/TryOUt/ClangC11/Deliv/Debug> export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
killerbot@XIII:~/Projects/TryOUt/ClangC11/Deliv/Debug> ./ClangC11
Segmentation fault
for a simple
#include <iostream>
int main()
{
std::cout << "Hello world!" << std::endl;
return 0;
}
In /usr/local/lin I also have the boost libs from my distro. I think these can be found by programs that need it ?
In /usr/local/lib64, the codeblocks so's end up. And when CB is launched (which is located in /usr/local/bin) that one is however able to find it's so files, while that path is also not in $LD_LIBRARY_PATH
for me it is :
echo $LD_LIBRARY_PATH
/usr/lib64/mpi/gcc/openmpi/lib64
So it seems there might be a few things going wrong, explicit path specification is bneeded, while other libs in there or in lib64 can be found, and in the end crash
build and installed clang and libc++ with your instructions, then let CB autodetect it, it finds it in /usr/local/clang.
...
Also my linux shell doesn't seem to know about clang (yet), though I did ldconfig, and /usr/local/bin is already in my path (this is also where codeblocks executable is).
It's probably not installed in /usr/local. Try:
find /usr/local -name clang++
EDIT : on the linking problem : added to Cb for clang compiler settings :
linker path : /usr/local/lib
link lib : c++
clang++ searches it's install-path/lib to find default libs.
==> links but at run time : error while loading shared libraries: libc++.so.1: cannot open shared object file: No such file or directory
A single call to ldconfig [/usr/local/lib] shoud do it. Check if '/usr/local/lib' is in the default lib-path:
grep 'usr/local' /etc/ld.so.conf
- osdt
all paths are in :
find /usr/local -name clang++
/usr/local/bin/clang++
grep 'usr/local' /etc/ld.so.conf
/usr/local/lib64
/usr/local/lib
so why does it not find the .so's
grep 'usr/local' /etc/ld.so.conf
/usr/local/lib64
/usr/local/lib
so why does it not find the .so's
Hmm ... did you run ldconfig after installation of libc++ successfully? Try ...
# run ldconfig
sudo /sbin/ldconfig
# check if libc++ has been found
sudo /sbin/ldconfig -p | grep 'libc++'
- osdt
one step further, I indeed forgot to rerun ldconfig, after I had build the libc++abi !
So now it links, and runs from within CB, and shell without LD_LIBRARY_PATH execution.
Well the "runs" ==> crashes
According to the debugger : in libcxxabi/src/cxa_exception.cpp
LIBCXXABI_NORETURN
void
__cxa_throw(void* thrown_object, std::type_info* tinfo, void (*dest)(void*))
{ /// <====================================== on this line stack ponter
during the call of : std::cout << "Hello world!" << std::endl;
just having a main that does return 0 ==> that doesn't crash