i new linux, , don't know need put clang pre-built binaries http://llvm.org/releases/download.html#3.3 . download it, unpack mouse, , add path /bin $path, , path /lib $ld_library_path, , add *.conf path /lib /etc/ld.so.conf.d . reboot notebook.
...but still cant build simple program code::blocks gcc (error: /home/aadgrand/tmp/llvm-3.3/final/llvm.src/lib/support/signals.cpp - undefined reference `dladdr'). text of test programm:
#include <iostream> #include "llvm/ir/module.h" #include "llvm/ir/llvmcontext.h" using namespace std; int main() { llvm::llvmcontext &c = llvm::getglobalcontext(); // error line cout << "never printed" << endl; return 0; }
what else need do? maybe need use *.sig-file? hm?
same question how install clang using precompiled binaries? . sorry repeat, interesting , important.
===== updated ======
i've insalled llvm-3.1, same error llvm-3.4 (from pre-built binaries):
-------------- build: debug in test2 --------------- compiling: main.cpp using built-in specs. collect_gcc=g++ collect_lto_wrapper=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper target: x86_64-linux-gnu configured with: ../src/configure -v --with-pkgversion='ubuntu/linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/readme.bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu thread model: posix gcc version 4.6.3 (ubuntu/linaro 4.6.3-1ubuntu5) collect_gcc_options='-std=c++98' '-pg' '-g' '-v' '-wall' '-fexceptions' '-i' '/usr/lib/llvm-3.1/include' '-c' '-o' 'obj/debug/main.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/4.6/cc1plus -quiet -v -i /usr/lib/llvm-3.1/include -imultilib . -imultiarch x86_64-linux-gnu -d_gnu_source /home/kpdev/projects/test2/test2/main.cpp -quiet -dumpbase main.cpp -mtune=generic -march=x86-64 -auxbase-strip obj/debug/main.o -g -wall -std=c++98 -version -p -fexceptions -fstack-protector -o /tmp/ccbkobdj.s gnu c++ (ubuntu/linaro 4.6.3-1ubuntu5) version 4.6.3 (x86_64-linux-gnu) compiled gnu c version 4.6.3, gmp version 5.0.2, mpfr version 3.1.0-p3, mpc version 0.9 ggc heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/llvm-3.1/include /usr/include/c++/4.6 /usr/include/c++/4.6/x86_64-linux-gnu/. /usr/include/c++/4.6/backward /usr/lib/gcc/x86_64-linux-gnu/4.6/include /usr/local/include /usr/lib/gcc/x86_64-linux-gnu/4.6/include-fixed /usr/include/x86_64-linux-gnu /usr/include end of search list. gnu c++ (ubuntu/linaro 4.6.3-1ubuntu5) version 4.6.3 (x86_64-linux-gnu) compiled gnu c version 4.6.3, gmp version 5.0.2, mpfr version 3.1.0-p3, mpc version 0.9 ggc heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 compiler executable checksum: 65b5171ac1bd7b3f07dbea6bdb24be3d /home/kpdev/projects/test2/test2/main.cpp: in function ‘int main()’: /home/kpdev/projects/test2/test2/main.cpp:11:24: warning: unused variable ‘c’ [-wunused-variable] collect_gcc_options='-std=c++98' '-pg' '-g' '-v' '-wall' '-fexceptions' '-i' '/usr/lib/llvm-3.1/include' '-c' '-o' 'obj/debug/main.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' --64 -o obj/debug/main.o /tmp/ccbkobdj.s compiler_path=/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/ library_path=/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../:/lib/:/usr/lib/ collect_gcc_options='-std=c++98' '-pg' '-g' '-v' '-wall' '-fexceptions' '-i' '/usr/lib/llvm-3.1/include' '-c' '-o' 'obj/debug/main.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' linking console executable: bin/debug/test2 /usr/lib/llvm-3.1/lib/libllvmsupport.a(signals.o): in function `printstacktrace(void*)': (.text+0x6c): undefined reference `dladdr' /usr/lib/llvm-3.1/lib/libllvmsupport.a(signals.o): in function `printstacktrace(void*)': (.text+0x187): undefined reference `dladdr' collect2: ld returned 1 exit status process terminated status 1 (0 minutes, 0 seconds) 2 errors, 1 warnings ||=== build finished: 2 errors, 1 warnings ===|
the title of question has misled both myself , atropo. looked if want install clang c++ compiler , build llvm c++ program in code::blocks.
what trying install clang+llvm (they different things) , build llvm program gcc in code::blocks. did "code::blocks gcc", assumed meant "i had code::blocks set gcc , want use clang". c::b build log have added, however, shows building gcc.
given building llvm program gcc not clear why want install clang compiler. perhaps want use clang not know code::blocks can support clang compiler, or not know how configure c::b use clang. let's take 1 thing @ time. can build llvm program gcc if things set properly. and - separate issue - can install clang properly. , - separate issue - can configure c::b build clang if want.
atropo pasted commands installing latest clang , debugger lldb. clang doesn't need llvm libraries , installing clang , lldb not give libraries need build llvm program.
you said in 1 of comments had been able build program clang++ in terminal. suggests had, @ point, working manual install of clang , llvm. don't know if still have 1 after intervening messing , anyway agree atropo manually installing such complex software - customizing path
, ld_library_path
etc. etc. - less sensible managed installation package repoository, letting package manager things right.
first, let's build llvm program gcc in c::b, , that, begin precautionary steps may or may not necessary:
undo customizing did , delete or conceal manually installed clang/llvm binaries.
get packages date. in console, run:
sudo apt-get update
ensure have basic packages building c/c++ software. in console, run:
sudo apt-get install build-essential
that finishes precautions. next:
install llvm standard ubuntu 12.04 repository. you'll old one, v2.9 that's fine now:
sudo apt-get install llvm
now you've got software need. keep console handy , launch c::b in simple llvm project.
as have standard system-install of llvm, change second 2
#include
directives of source code following:#include <llvm/module.h>
#include <llvm/llvmcontext.h>
get llvm tell compiler options need pass gcc. in console run:
llvm-config --cxxflags
copy output of command console clipboard. in c::b, open project's build options , navigate compiler settings -> other options gcc. in other options edit-box, paste in compiler options clipboard , ok it.
get llvm tell libraries need link. in console run:
llvm-config --libs
copy output of command console clipboard (this time there lot of it). in c::b, navigate build options -> linker settings -> other linker options. in edit-box, paste in library options clipboard , ok it.
get llvm tell (other) options need pass linker. in console run:
llvm-config --ldflags
copy output of command console clipboard. in c::b, navigate, once again, build options -> linker settings -> other linker options in edit-box, after - repeat, after - library options have pasted there, paste in additional linker options clipboard , ok it.
now rebuild project , time compile , link only warning unused variable
c
(at least me).
that covers building program. if run it, output "never printed", guess don't want to; that's problem :) builds , runs.
if want install latest llvm , clang packages, read on.
install llvm toolchain repository, ubuntu 12.04, in software sources
sudo add-apt-repository 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise main'
install gpg key of repository authenticate package downloads it. note final hyphen on commandline:
wget -o - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add -
refresh package database again:
sudo apt-get update
install whole llvm+clang toolchain:
sudo apt-get install clang-3.4 clang-3.4-doc libclang-common-3.4-dev libclang-3.4-dev libclang1-3.4 libclang1-3.4-dbg libllvm-3.4-ocaml-dev libllvm3.4 libllvm3.4-dbg lldb-3.4 llvm-3.4 llvm-3.4-dev llvm-3.4-doc llvm-3.4-examples llvm-3.4-runtime cpp11-migrate-3.4 clang-format-3.4
prove have got clang 3.4:
clang -v
this command should output:
ubuntu clang version 3.4-1~exp1 (trunk) (based on llvm 3.4) target: x86_64-pc-linux-gnu thread model: posix
finally, might want configure c::b use clang instead of gcc. started.
- in c::b, navigate compiler settings gcc , click copy button. in add new compiler edit-box, enter
clang-3.4
, click ok. follow prompt c::b gives update "toolchain executables" page.
Comments
Post a Comment