News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

LLVM/Clang compiler for MinGW

Started by MortenMacFly, January 22, 2013, 07:30:14 AM

Previous topic - Next topic

killerbot

on your instructions for building libcxx :

mkdir build-release
cd  build-release  <======================
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..

killerbot

#16
build and installed clang and libc++ with your instructions, then let CB autodetect it, it finds it in /usr/local/clang.

But when trying a "hello world" , it fails to compile since it doesn't ind the headers (iostream).
What should be the correct location ?
Timestamps wise I think this was a result of the build too : /usr/local/include/c++/v1/ ? => when using this , compiles but now linker problems (eg . :  main.cpp:4: undefined reference to `std::__1::cout')

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).

EDIT : on the linking problem : added to Cb for clang compiler settings :
linker path : /usr/local/lib
link lib : c++

==> links but at run time :  error while loading shared libraries: libc++.so.1: cannot open shared object file: No such file or directory

eranif

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:

cd libcxxabi/lib


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:
./buildit

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

killerbot

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

eranif

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

killerbot

I did not do the export (export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH) , but it is in my normal path, is that not sufficient ?
And in the compiler settings of clang in CB, I even added that path as the dirs where the linker can go find libs.

I did create the 2 symlinks.

eranif

Quotebut it is in my normal path, is that not sufficient
Do you mean its in your PATH environment variable? LD_LIBRARY_PATH is for locating libraries during runtime
PATH is used to locate binaries (unlike Windows...)

QuoteI even added that path as the dirs where the linker can go find libs
And from what I understood the linker did _find_ it. Its just that the runtime linker did not find them (it needs LD_LIBRARY_PATH)

Eran

killerbot

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

eranif

BTW, which distro do you use?

I am using Ubuntu 12.10/64
and it is running without a problem...

Can you post the compiler output and the linker ?


Eran

osdt

Quote from: killerbot on May 04, 2013, 07:59:19 PM
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++


Quote from: killerbot on May 04, 2013, 07:59:19 PM
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.

Quote from: killerbot on May 04, 2013, 07:59:19 PM
==> 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


Jenna

I can compile C::B with clang (except for thre contrib-plugins, LibFinder, Profiler and NassiShneiderman) without any tweaking or self-compiling of clang on Fedora 18.
And it seems to run (at least it starts without issues.
C::B from inside C::B.
Compiler is detected as gcc 4.1.2 on starthere-page.

Alpha

If you do not have a particular reason to self-compile Clang, installing it through apt-get works fine.

Quote from: jens on May 05, 2013, 04:23:49 PM
I can compile C::B with clang (except for thre contrib-plugins, LibFinder, Profiler and NassiShneiderman) without any tweaking or self-compiling of clang on Fedora 18.
And it seems to run (at least it starts without issues.
C::B from inside C::B.
Also works in Ubuntu 12.04 and 13.04.

eranif

QuoteIf you do not have a particular reason to self-compile Clang, installing it through apt-get works fine
I think that the problem here is not compiling clang (from what I understand killerbot we are beyond it)
We are trying to make clang to use a different std++ library named "libc++" which on linux also requires libc++abi
both needs to be self compiled (libc++abi build instructions are only available for OSX and not for Linux not to mention Windows...)

Eran

killerbot

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

osdt

Quote from: killerbot on May 06, 2013, 08:00:32 PM

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