OpenCV version 3.4 undefined reference to `cv::bgsegm::createBackgroundSubtractorMOG(int, int, double, double)'
Hello everyone, The OpenCV version I'm currently using is OpenCV 3.4 .
I'm trying to compile a sample program from github. But, I'm receiving the following errors:
/tmp/cctdl0lP.o: In function `createBGSubtractorByName(cv::String const&)':
bgfg.cpp:(.text+0xfd): undefined reference to `cv::bgsegm::createBackgroundSubtractorGMG(int, double)'
bgfg.cpp:(.text+0x190): undefined reference to `cv::bgsegm::createBackgroundSubtractorCNT(int, bool, int, bool)'
bgfg.cpp:(.text+0x2b8): undefined reference to `cv::bgsegm::createBackgroundSubtractorMOG(int, int, double, double)'
collect2: error: ld returned 1 exit status
I found the similar problem referred here. And hence I included the following:
#ifdef _DEBUG
#pragma comment(lib, "opencv_bgsegm340d.lib")
#else
#pragma comment(lib, "opencv_bgsegm340.lib")
#endif
Yet, the problem doesn't seem to be solved. Kindly, help.
Thanks in advance.
What is your platform ? May be I'm wrong but pragma comment(lib, is for msvc and error: ld returned 1 exit status is a link error for gcc or mingw?
To me it seems your simply linking the wrong libraries in your project settings.... it tells you it cannot find the corresponding function in its linked libraries.
I just found out that the OpenCV version that I recently installed(i.e. version 3.4.0) doesn't have opencv_bgsegm340.lib. does this mean I haven't installed OpenCV properly, or the version doesn't have it at all?
@LBerger the platform I'm working on is g++.
g++ lib is libopencv_bgsegm340 ? #pragma comment(lib, " is it a directive for g++?
@LBerger well, No. It is a library to include few background subtraction modules such as MOG and GMG. Unfortunately, when I installed the OpenCV 3.4 version, this and few other library did not get copied to the location. I had to make few changes in my Makefile to get over this problem. Anyway, Thanks for your time and help. :)