OpenCV-4.5.2 GNU-G++-11.1.0 MacOS-10.13.6 Build Error

I’m trying to build OpenCV-4.5.2 on MacOS-10.13.6 using GNU-G+±11.1.0.

It works up to build/modules/videoio, trying to link libopencv_videoio.4.5.2.dylib where it throws some errors…

Undefined symbols for architecture x86_64:
“__ZNKSt3__119__shared_weak_count13__get_deleterERKSt9type_info”, referenced from:
__ZTVNSt3__120__shared_ptr_emplaceIN2cv13LegacyCaptureENS_9allocatorIS2_EEEE in cap_avfoundation_mac.mm.o

… and a few more. NOTE: this link command is missing “-lc++”, which when added mostly fixes these issues, but theres still two unresolved symbols…

Undefined symbols for architecture x86_64:

“__ZN2cv26create_AVFoundation_writerERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEidRKNS_5Size_IiEERKNS_21VideoWriterParametersE”, referenced from:
__GLOBAL__sub_I_videoio_registry.cpp in videoio_registry.cpp.o
“__ZN2cv32create_AVFoundation_capture_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE”, referenced from:
__GLOBAL__sub_I_videoio_registry.cpp in videoio_registry.cpp.o

“create_AVFoundation_writer” and “create_AVFoundation_capture_file”, seem to be in both
modules/videoio/src/cap_avfoundation.mm and modules/videoio/src/cap_avfoundation_mac.mm. The link command is pulling in the object file from that second (_mac) source, but those two symbols are still unresolved.

Any clues as to how to resolve this would be greatly appreciated!

Hello, I have the same problem, Did you have solved it? could you please share any info about the solutions? sincerely looking forward to your reply.