0

I want to cross-compile my program,so I wrote a 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)*

I added all linker of my libraries in the makefile but when I run make I got these errors but I didn't understand how to fix it:

    ./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

1 Answers1

1

First thing to understand, is that you are getting a linker error.

Then note that you are trying to use cv::groupRectangles and the linker fails at linking it. According to the openCV documentation it is part of the Object Detection module.

I searched in the internet for "OpenCV Object Detection tutorials" and they are all linking opencv_objdetect in their make files. So try adding -lopencv_objdetect to the third line in your makefile where you define the variable OPENCV and see if that helps.

Potaito
  • 1,181
  • 2
  • 10
  • 32