我想交叉编译我的程序,所以我写了一个makefile:
CC= arm-buildroot-linux-gnueabihf-g++
CFLAGS= -W -Wall -v -O3 -ftree-vectorize -std=c++0x
OPENCV= -I '/home/slim/Desktop/buildroot-2016.02/output/staging/usr/include/' -L '/home/slim/Desktop/buildroot-2016.02/output/staging/usr/lib' -lopencv_core -lopencv_highgui -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_imgproc -lopencv_video
BIN = ./bin/
all: detection.o Ctracker.o HungarianAlg.o Kalman.o
$(CC) $(CFLAGS) $(BIN)detection.o $(BIN)Ctracker.o $(BIN)HungarianAlg.o $(BIN)Kalman.o -o dect $(OPENCV)
detection.o: Ctracker.h detection.cpp
$(CC) $(CFLAGS) $(OPENCV) -c detection.cpp -o $(BIN)detection.o
Ctracker.o: Ctracker.h HungarianAlg.h Kalman.h
$(CC) $(CFLAGS) $(OPENCV) -c Ctracker.cpp -o $(BIN)Ctracker.o
HungarianAlg.o: HungarianAlg.h
$(CC) $(CFLAGS) $(OPENCV) -c HungarianAlg.cpp -o $(BIN)HungarianAlg.o
Kalman.o: HungarianAlg.h
$(CC) $(CFLAGS) -c Kalman.cpp -o $(BIN)Kalman.o
clean:
rm $(BIN)*
我在makefile中添加了我的库的所有链接器但是当我运行make时遇到了这些错误,但我不明白如何解决它:
./bin/detection.o: In function `drawBoundingBox(std::vector<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >, std::allocator<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > > >)':
detection.cpp:(.text+0x46c): undefined reference to `cv::groupRectangles(std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, int, double)'
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
答案 0 :(得分:1)
首先要了解的是,您收到链接器错误。
然后请注意,您正在尝试使用cv::groupRectangles
,并且链接器在链接时失败。根据{{3}},它是对象检测模块的一部分。
我在互联网上搜索了“OpenCV对象检测教程”,他们都在其make文件中链接 opencv_objdetect 。因此,请尝试将-lopencv_objdetect
添加到您定义变量OPENCV
的makefile中的第三行,看看是否有帮助。