1

我正在尝试将 LLVM 优化应用于已使用 openCV 实现的一些图像特征提取算法。基于 LLVM 的分析器适用于简单的程序(例如 HelloWorld),并且特征提取算法也可以按预期单独工作。但是,我无法将分析器用于算法,并且在将 OpenCV 库链接到优化代码时出现以下错误。

gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 
COLLECT_GCC_OPTIONS='-v' '-g' '-L/home/silky/opencv/share/OpenCV/3rdparty/lib' '-  L/home/silky/opencv/OpenCVInstall/x86/lib' '-shared-libgcc' '-mtune=generic' '-march=x86-64' as --gdwarf2 --64 -o /tmp/ccAhPffW.o out.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='-v' '-g' '-L/home/silky/opencv/share/OpenCV/3rdparty/lib' '-L/home/silky/opencv/OpenCVInstall/x86/lib' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/4.6/collect2 --sysroot=/ --build-id --no-add-needed --as-needed --eh-frame-hdr -m elf_x86_64 --hash-style=gnu -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.6/crtbegin.o -L/home/silky/opencv/share/OpenCV/3rdparty/lib -L/home/silky/opencv/OpenCVInstall/x86/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6 -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../.. /tmp/ccAhPffW.o -lpthread -lrt -lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_video -lopencv_nonfree -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.6/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crtn.o
/tmp/ccAhPffW.o:(.debug_info+0x49a14): undefined reference to `.Lline_table_start1'
collect2: ld returned 1 exit status

我使用以下命令来编译和链接文件。

clang -emit-llvm -c -Wall -g  -O0  -DCLOCK_GETTIME_TIMING -DOPENCV_2_4  -I/home/opencv/OpenCVInstall/x86/include -o ThreadManager.bc FeatureExtraction/ThreadManager.cpp
clang -emit-llvm -c -Wall -g  -O0  -DCLOCK_GETTIME_TIMING -DOPENCV_2_4 -I/home/opencv/OpenCVInstall/x86/include -o FeatureExtraction.bc FeatureExtraction/FeatureExtraction.cpp

llvm-link  FeatureExtraction.bc ThreadManager.bc -o FE.bc
clang $CFLAGS -o profiler.o cacheSim.cpp //LLVM profiler
opt -load /home/llvm/llvm/Debug+Asserts/lib/cacheProf.so -cacheProf FE.bc>out.bc

llc FE.bc -o out.s
g++ -v -g  out.s  profiler.o -L/home/opencv/share/OpenCV/3rdparty/lib -L/home/opencv/OpenCVInstall/x86/lib  -lpthread -lrt -lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_video -lopencv_nonfree

如果我链接文件或以错误的方式加载文件,有人可以告诉我吗?clang 编译与 g++ 的工作方式不同吗?

4

0 回答 0