我对 linux 很陌生,不知道我需要将 Clang 预构建的二进制文件放在哪里http://llvm.org/releases/download.html#3.3 。我下载它,用鼠标解压,然后将 /bin 的路径添加到我的 $PATH,将 /lib 的路径添加到 $LD_LIBRARY_PATH,然后将 *.conf 和 /lib 的路径添加到 /etc/ld.so.conf.d . 我什至重新启动我的笔记本电脑。
...但仍然无法使用 Code::Blocks GCC 构建我的简单程序(错误:/home/aadgrand/tmp/LLVM-3.3/final/llvm.src/lib/Support/Signals.cpp - 未定义对“dladdr”的引用)。测试程序的文本:
#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;
}
我还需要做什么?也许我需要使用 *.sig 文件?嗯?
与如何使用预编译的二进制文件安装 CLang 相同的问题?. 抱歉重复一遍,但这真的很有趣也很重要。
===== 更新 ======
我刚刚安装了 llvm-3.1,与 llvm-3.4 相同的错误(来自预构建的二进制文件):
-------------- 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 by 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 by 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'
as --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 to `dladdr'
/usr/lib/llvm-3.1/lib/libLLVMSupport.a(Signals.o): In function `PrintStackTrace(void*)':
(.text+0x187): undefined reference to `dladdr'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 1 warnings
||=== Build finished: 2 errors, 1 warnings ===|