Symbol not defined in any opencv library


I am trying to compile a cpp file with link against OpenEXR and OpenCV as follows. I am working on a Mac M1.

g++-11 $(pkg-config --cflags --libs opencv4) $(pkg-config --cflags --libs OpenEXR) exr2dpt.cpp -o exr2dpt

However, it raises two undefined symbols.

"__ZN2cv4globENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIS5_SaIS5_EEb", referenced from:
      _main in ccQDJc9x.o
"__ZN2cv5errorEiRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKcS9_i", referenced from:
      __ZN2cv4Mat_IfEaSERKNS_3MatE in ccQDJc9x.o

I tried to look which symbols export the opencv libraries and I couldn’t find exactly those symbols. I found similar ones:
./libopencv_core.4.5.5.dylib:938:0000000000065850 T __ZN2cv4globENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERNS0_6vectorIS6_NS4_IS6_EEEEb
./libopencv_core.4.5.5.dylib:967:000000000015af1c T __ZN2cv5errorEiRKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEPKcSA_i

Any ideas what can I be doing wrong? Thanks!

My bad. I had to compile with clang++ instead of g++-11

1 Like