[cfe-users] installing a complete clang++ environment

Bill White bill.white at griggsinst.com
Mon Sep 29 07:52:56 PDT 2014


When I do this I install clang a directory whose name is in the path named
by the envariable "CLANG_DIR", and put the clang version in the envariable
named "CLANG_VERSION".

1. Then I compile using the command
      "clang++ -nostdinc++ -std=c++11 -isystem
${CLANG_DIR}/lib/clang/${CLANG_VERSION}/include ..."
2. Then I link using the command
      "clang++ -nostdinc++ -std=c++11 -L${CLANG_DIR}/lib -stdlib=libc++
-lc++"

I actually put all this in a CMakefile, and then generally forget what I
have done.

Variants of this let me build boost, poco, log4cpp and some other standard
libraries with clang and libc++.
For boost and poco you need to figure out how to use their build system,
which is harrowing, but
possible.  For autoconf style systems you need to train them to not use
libstdc++, which they really,
really want to do.  For me, this typically means editing the configure
script after autoconf does its
generation magic, since I'm too impatient and bored to figure out what
autoconf and automake really
are trying to do.  (Log4cpp is an autoconf project.)


On Mon, Sep 29, 2014 at 10:09 AM, Klaus Rudolph <lts-rudolph at gmx.de> wrote:

> Ups forgett to tell you that the install script also fails:
>
> -- Installing: /usr/local/include/lldb/Symbol/TypeVendor.h
> -- Installing: /usr/local/include/lldb/Symbol/ObjectContainer.h
> -- Installing: /usr/local/include/lldb/Symbol/VerifyDecl.h
> -- Installing: /usr/local/include/lldb/Symbol/TypeList.h
> CMake Error at tools/lldb/scripts/cmake_install.cmake:36 (FILE):
>   file INSTALL cannot find
>   "/home/krud/work/clang_complett_aus_source/build/lib/python2.7".
> Call Stack (most recent call first):
>   tools/lldb/cmake_install.cmake:42 (INCLUDE)
>   tools/cmake_install.cmake:70 (INCLUDE)
>   cmake_install.cmake:61 (INCLUDE)
>
>
>
>
> > Gesendet: Montag, 29. September 2014 um 16:08 Uhr
> > Von: "Klaus Rudolph" <lts-rudolph at gmx.de>
> > An: "Klaus Rudolph" <lts-rudolph at gmx.de>
> > Cc: "Eugene Golovachev" <kamelusz at yandex.ru>, cfe-users at cs.uiuc.edu
> > Betreff: Aw: Re: [cfe-users] installing a complete clang++ environment
> >
> > Additional info:
> >
> > After i patched tons of flags.make files to include the correct include
> path I can compile.
> > BUT a make install distroys my linux! The install goes to
> /usr/local/include/ instead of /opt...
> >
> > WOW!
> >
> > OK, I will now install my system again! I'll be back in a few days...
> >
> >
> >
> > > Gesendet: Montag, 29. September 2014 um 14:44 Uhr
> > > Von: "Klaus Rudolph" <lts-rudolph at gmx.de>
> > > An: "Eugene Golovachev" <kamelusz at yandex.ru>
> > > Cc: cfe-users at cs.uiuc.edu
> > > Betreff: Re: [cfe-users] installing a complete clang++ environment
> > >
> > > Thanks for your reply!
> > >
> > > After several hours of trying I can't get it to work! :-(
> > >
> > > I run into trouble with:
> > >
> > >
> > > [ 98%] Built target lldb-platform
> > > [ 98%] Building CXX object
> tools/extra/clang-apply-replacements/CMakeFiles/clangApplyReplacements.dir/lib/Tooling/ApplyReplacements.cpp.o
> > > In file included from
> /home/krud/work/clang_complett_aus_source/src/tools/extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp:17:
> > >
> /home/krud/work/clang_complett_aus_source/src/tools/extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h:19:10:
> fatal error:
> > >       'clang/Tooling/Refactoring.h' file not found
> > > #include "clang/Tooling/Refactoring.h"
> > >
> > >
> > > Any hints?
> > >
> > > Regards
> > >  Klaus
> > >
> > >
> > > > Gesendet: Freitag, 26. September 2014 um 19:21 Uhr
> > > > Von: "Eugene Golovachev" <kamelusz at yandex.ru>
> > > > An: cfe-users at cs.uiuc.edu
> > > > Betreff: Re: [cfe-users] installing a complete clang++ environment
> > > >
> > > > I perform the next steps to get working Clang and libc++ on my
> Gentoo box:
> > > >
> > > > 1) Download packages llvm-3.5.0.src.tar.xz, lldb-3.5.0.src.tar.xz,
> > > > libcxx-3.5.0.src.tar.xz, libcxxabi-3.5.0.src.tar.xz,
> > > > compiler-rt-3.5.0.src.tar.xz, cfe-3.5.0.src.tar.xz,
> > > > clang-tools-extra-3.5.0.src.tar.xz from http://llvm.org/releases/
> > > >
> > > > 2) Extract them:
> > > > $ mkdir -pv ~/src/llvm/release_35
> > > >
> > > > $ tar xfv llvm-3.5.0.src.tar.xz --strip-components=1 -C
> > > > ~/src/llvm/release_35/
> > > >
> > > > $ mkdir -pv
> ~/src/llvm/release_35/projects/{libcxx,libcxxabi,compiler-rt}
> > > > $ tar xfv libcxx-3.5.0.src.tar.xz --strip-components=1 -C
> > > > ~/src/llvm/release_35/projects/libcxx/
> > > > $ tar xfv libcxxabi-3.5.0.src.tar.xz --strip-components=1 -C
> > > > ~/src/llvm/release_35/projects/libcxxabi/
> > > > $ tar xfv compiler-rt-3.5.0.src.tar.xz --strip-components=1 -C
> > > > ~/src/llvm/release_35/projects/compiler-rt/
> > > >
> > > > $ mkdir -pv ~/src/llvm/release_35/tools/{clang,lldb}
> > > > $ tar xfv cfe-3.5.0.src.tar.xz --strip-components=1 -C
> > > > ~/src/llvm/release_35/tools/clang/
> > > > $ tar xfv lldb-3.5.0.src.tar.xz --strip-components=1 -C
> > > > ~/src/llvm/release_35/tools/lldb/
> > > >
> > > > $ mkdir -pv ~/src/llvm/release_35/tools/clang/tools/extra
> > > > $ tar xfv clang-tools-extra-3.5.0.src.tar.xz --strip-components=1 -C
> > > > ~/src/llvm/release_35/tools/clang/tools/extra/
> > > >
> > > > 3) And compile using cmake and Clang 3.3 from Gentoo portages:
> > > > $ mkdir -pv ~/build
> > > > $ cd ~/build
> > > >
> > > > $ CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake
> > > > -DCMAKE_INSTALL_PREFIX=~/opt/clang-3.5.0-release/
> > > > -DCMAKE_BUILD_TYPE=Release ~/src/llvm/release_35/
> > > >
> > > > $ make -j3
> > > > $ make install
> > > >
> > > > 4) As result I have working Clang with libc++ support. For linking
> with
> > > > libc++ it necessary to set LD_LIBRARY_PATH environment variable:
> > > > $ export LD_LIBRARY_PATH=~/opt/clang-3.5.0-release/lib/
> > > >
> > > > And now I can use Clang with libc++:
> > > > $ ~/opt/clang-3.5.0-release/bin/clang++ -stdlib=libc++ -nodefaultlibs
> > > > -lc++ -lc++abi -lm -lc -lgcc_s -lgcc main.cpp
> > > > $ ./a.out
> > > > Hello off, world!
> > > _______________________________________________
> > > cfe-users mailing list
> > > cfe-users at cs.uiuc.edu
> > > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users
> > >
> >
> _______________________________________________
> cfe-users mailing list
> cfe-users at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140929/720fbda7/attachment.html>


More information about the cfe-users mailing list