Qt5.1/Qt5.2 + Mac OS 10.9 (Mavericks) + XCode 5.0.2, Undefined symbols for architecture x86_64

前端 未结 3 2120
遥遥无期
遥遥无期 2020-12-05 09:00

Environment : Mac OS 10.9 + Qt5.1/Qt5.2 + OpenCV2.4.7 + XCode(5.0.2)

I can compile the following program via terminal

g++ -L/usr/local/lib -lopencv_         


        
3条回答
  •  有刺的猬
    2020-12-05 09:24

    This issue is answered in this post

    http://qt-project.org/forums/viewthread/35646/

    and explained by sandy.martel

    I quoted here

    Qt binary distribution compile with -stdlib=libstdc++ to be compatible with 10.6, Xcode 5 on 10.9 will select -stdlib=libc++ by default (for OS X 10.7 and better only). So symbol using classes from the standard library (like std::string in this case) will not resolve correctly at link time. This is why you’re seeing this error (Undefined symbols for architecture x86_64) . Look with which standard library opencv is built: otool -L libopencv_XXX.dylib. You’ll have to rebuild it with the right one or change Qt’s mkspec to use the newer one.

    I solve this by changing ../Qt5.2.0/5.2.0-rc1/clang_64/mkspecs/macx-clang/qmake.conf

    from

    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
    

    to

    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
    

    And remember clean your project before rebuild.

提交回复
热议问题