0

I've some troubles compiling opencv sample for videocapture, link here.

The following is a part of the errors I get (some involving ffmpeg). I've tried many combinations of linking and compilation flags but with no luck. Where's the problem?

 g++ -pthread -o test test.cpp `pkg-config --cflags --libs opencv`
/usr/local/lib/libopencv_highgui.a(window.cpp.o): In function `cv::getWindowImageRect(cv::String const&)':
window.cpp:(.text._ZN2cv18getWindowImageRectERKNS_6StringE+0x2e): undefined reference to `cv::utils::trace::details::Region::Region(cv::utils::trace::details::Region::LocationStaticStorage const&)'
window.cpp:(.text._ZN2cv18getWindowImageRectERKNS_6StringE+0x6b): undefined reference to `cv::utils::trace::details::Region::destroy()'
window.cpp:(.text._ZN2cv18getWindowImageRectERKNS_6StringE+0x9e): undefined reference to `cv::utils::trace::details::Region::destroy()'
/usr/local/lib/libopencv_highgui.a(window.cpp.o): In function `cv::namedWindow(cv::String const&, int)':
window.cpp:(.text._ZN2cv11namedWindowERKNS_6StringEi+0x2b): undefined reference to `cv::utils::trace::details::Region::Region(cv::utils::trace::details::Region::LocationStaticStorage const&)'
window.cpp:(.text._ZN2cv11namedWindowERKNS_6StringEi+0x54): undefined reference to `cv::utils::trace::details::Region::destroy()'
window.cpp:(.text._ZN2cv11namedWindowERKNS_6StringEi+0x84): undefined reference to `cv::utils::trace::details::Region::destroy()'
/usr/local/lib/libopencv_highgui.a(window.cpp.o): In function `cv::destroyWindow(cv::String const&)':
window.cpp:(.text._ZN2cv13destroyWindowERKNS_6StringE+0x27): undefined reference to `cv::utils::trace::details::Region::Region(cv::utils::trace::details::Region::LocationStaticStorage const&)'
window.cpp:(.text._ZN2cv13destroyWindowERKNS_6StringE+0x4e): undefined reference to `cv::utils::trace::details::Region::destroy()'
window.cpp:(.text._ZN2cv13destroyWindowERKNS_6StringE+0x7c): undefined reference to `cv::utils::trace::details::Region::destroy()'
/usr/local/lib/libopencv_highgui.a(window.cpp.o): In function `cv::destroyAllWindows()':
window.cpp:(.text._ZN2cv17destroyAllWindowsEv+0x24): undefined reference to `cv::utils::trace::details::Region::Region(cv::utils::trace::details::Region::LocationStaticStorage const&)'
window.cpp:(.text._ZN2cv17destroyAllWindowsEv+0x39): undefined reference to `cv::utils::trace::details::Region::destroy()'
window.cpp:(.text._ZN2cv17destroyAllWindowsEv+0x67): undefined reference to `cv::utils::trace::details::Region::destroy()'
/usr/local/lib/libopencv_highgui.a(window.cpp.o): In function `cv::resizeWindow(cv::String const&, int, int)':
window.cpp:(.text._ZN2cv12resizeWindowERKNS_6StringEii+0x30): undefined reference to `cv::utils::trace::details::Region::Region(cv::utils::trace::details::Region::LocationStaticStorage const&)'
window.cpp:(.text._ZN2cv12resizeWindowERKNS_6StringEii+0x5c): undefined reference to `cv::utils::trace::details::Region::destroy()'
window.cpp:(.text._ZN2cv12resizeWindowERKNS_6StringEii+0x8e): undefined reference to `cv::utils::trace::details::Region::destroy()'
/usr/local/lib/libopencv_highgui.a(window.cpp.o): In function `cv::resizeWindow(cv::String const&, cv::Size_<int> const&)':
window.cpp:(.text._ZN2cv12resizeWindowERKNS_6StringERKNS_5Size_IiEE+0x2c): undefined reference to `cv::utils::trace::details::Region::Region(cv::utils::trace::details::Region::LocationStaticStorage const&)'

I've tried both:

g++ -o test test.cpp -pthread `pkg-config --cflags --libs opencv`

and

g++ -o test test.cpp `pkg-config --cflags --libs opencv` -pthread

but didn't fix.

Surfer on the fall
  • 721
  • 1
  • 8
  • 34
  • Does this Q&A relate to your problem?: https://stackoverflow.com/a/7816668/3648282 --- Hint: Answer suggests library order, g++ -o test_1 test_1.cpp `pkg-config opencv --cflags --libs` – Rob Mar 18 '18 at 17:28
  • @Rob it doesn't seem enough to fix.. updated question.. – Surfer on the fall Mar 18 '18 at 17:57
  • I'm on mobile while my computer is down so can't be a lot of help. From memory, years ago: Up a directory or two there's an example makefile that should *just work* (but compiles **all** the examples), as the command line whizzes by there ought to be your answer - if you can't simply compile the main example (as opposed to picking a single file) there's something incorrect with your build environment (or a needed file isn't present / added to a .lib) . – Rob Mar 18 '18 at 18:14
  • It works for me. Add your distro and the steps by which you installed the opencv dev files. May be something wrong there. – Mike Kinghan Mar 18 '18 at 18:56

0 Answers0