Apple Mach-O linker and multiple “undefined symbols” error using OpenCV

后端 未结 5 1499
忘掉有多难
忘掉有多难 2020-12-02 11:25

I am currently a real beginner in Objective C, and I am developing an app using the framework OpenCV.

I am following a tutorial, but while builing the project, I got

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 11:53

    This actually seems to hide the actual problem: the fact that your LLVM compiler may not choose a proper standard C++ library for compiling by default. You should go to

    Project (or your Target) -> Build Settings -> Apple LLVM 6.0 - Language - C++ -> C++ Standard Library

    and make sure that you pick libc++ as your choice, not just Compiler Default, since modern OpenCV library is linked against libc++. This will solve your problem without having to add the extra libc++.dylib. Including libc++.dylib framework as a workaround will not always work out if your Compiler Default actually does not choose libc++ library!

    To check what "Compiler Default" is, you can do something like this. Mine somehow chooses c++98 as a default.

提交回复
热议问题