OpenCV3.0 Compile issues, undefined references

asked 2015-06-05 03:19:06 -0600

olinguyen gravatar image

I'm trying to compile some simple code, but keep getting undefined references. I tried adding

-Wl,--start-group [libs] -Wl, --end-group

But still no success. I think I did my installation properly since I am able to build the samples/examples of OpenCV 3.0 rc1 properly with the Makefile provided. Note that I am running on Ubuntu 14.04.

However, I can't seem to be able manually compile OpenCV code. For example:

g++ lkdemo.cpp -o lkdemo -Wl,--start-group -lopencv_highgui -lopencv_video -lopencv_imgproc -lavformat -lavdevice -lavutil -lavcodec -lswscale -lopencv_core -Wl,--end-group
/tmp/ccU9sgJM.o: In function `main':
lkdemo.cpp:(.text+0x125): undefined reference to `cv::VideoCapture::VideoCapture()'
lkdemo.cpp:(.text+0x223): undefined reference to `cv::VideoCapture::open(int)'
lkdemo.cpp:(.text+0x267): undefined reference to `cv::VideoCapture::open(cv::String const&)'
lkdemo.cpp:(.text+0x285): undefined reference to `cv::VideoCapture::isOpened() const'
lkdemo.cpp:(.text+0x384): undefined reference to `vtable for cv::VideoCapture'
lkdemo.cpp:(.text+0xd78): undefined reference to `cv::VideoCapture::~VideoCapture()'
lkdemo.cpp:(.text+0x103a): undefined reference to `cv::VideoCapture::~VideoCapture()'
collect2: error: ld returned 1 exit status

The error I am most concerned about is the one below.

=== linking: release/DenseTrack ===
g++ -L/opt/lib -pipe -Wall -O3 -ggdb -o release/DenseTrack .build_release/DenseTrack.o -lopencv_highgui -lopencv_video -lopencv_imgproc -lavformat -lavdevice -lavutil -lavcodec -lswscale -lopencv_core
.build_release/DenseTrack.o: In function `HogComp(cv::Mat const&, float*, DescInfo&)':
dense_trajectory_release_v1.2/Descriptors.h:118: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
dense_trajectory_release_v1.2/Descriptors.h:118: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
dense_trajectory_release_v1.2/Descriptors.h:119: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
dense_trajectory_release_v1.2/Descriptors.h:119: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
.build_release/DenseTrack.o: In function `MbhComp(cv::Mat const&, float*, float*, DescInfo&)':
dense_trajectory_release_v1.2/Descriptors.h:138: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
dense_trajectory_release_v1.2/Descriptors.h:138: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
dense_trajectory_release_v1.2/Descriptors.h:139: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
dense_trajectory_release_v1.2/Descriptors.h:139: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
dense_trajectory_release_v1.2/Descriptors.h:140: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
dense_trajectory_release_v1.2/Descriptors.h:140: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
dense_trajectory_release_v1.2/Descriptors.h:141: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
dense_trajectory_release_v1.2/Descriptors.h:141: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
.build_release/DenseTrack.o: In function `DrawTrack(std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > > const&, int, float, cv::Mat&)':
dense_trajectory_release_v1.2/Descriptors.h:289: undefined reference to `cv::line(cv::Mat&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
dense_trajectory_release_v1.2/Descriptors.h:292: undefined reference to `cv::circle(cv::Mat&, cv::Point_<int>, int, cv::Scalar_<double> const&, int, int, int)'
.build_release/DenseTrack.o: In function `my::MedianBlurFlow(cv::Mat&, int)':
dense_trajectory_release_v1.2/OpticalFlow.h:406: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
dense_trajectory_release_v1.2/OpticalFlow.h:406 ...
(more)
edit retag flag offensive close merge delete

Comments

  • you need -lopencv_videoio for VideoCapture (new module in 3.0)
berak gravatar imageberak ( 2015-06-05 03:25:43 -0600 )edit