Qt5.2.1 Mac 10.9 Undefined symbols for architecture x86_64 错误解决

更新Mac 10.9.2后,之前的Qt程序运行出现以下错误:

Undefined symbols for architecture x86_64:

  "___sincos_stret", referenced from:
      ...
  "___sincos_stret", referenced from:
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [trimeshview.app/Contents/MacOS/trimeshview] Error 1
14:30:06: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project trianglemesh (kit: Desktop Qt 5.2.1 clang 64bit)
When executing step 'Make'
14:30:06: Elapsed time: 00:16.

原因是编译器和sdk版本不匹配,需要在项目中添加:

macx:QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
macx:QMAKE_MAC_SDK=macosx10.9


注:如果Qt出现编译问题,可直接查看生成的makefile文件获取错误信息,本次错误状态下,makefile文件如下:

Release:


/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -isysroot /Developer/SDKs/MacOSX10.9.sdk -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.9 -Wall -W -fPIE -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../Tools/Qt/5.2.1/clang_64/mkspecs/macx-clang -I../trianglemesh -I../trianglemesh/include -I../../Tools/Qt/5.2.1/clang_64/lib/QtOpenGL.framework/Versions/5/Headers -I../../Tools/Qt/5.2.1/clang_64/lib/QtWidgets.framework/Versions/5/Headers -I../../Tools/Qt/5.2.1/clang_64/lib/QtGui.framework/Versions/5/Headers -I../../Tools/Qt/5.2.1/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/zdd/Tools/Qt/5.2.1/clang_64/lib -o main.o ../trianglemesh/main.cpp

Debug:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -isysroot /Developer/SDKs/MacOSX10.9.sdk -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.9 -Wall -W -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../Tools/Qt/5.2.1/clang_64/mkspecs/macx-clang -I../trianglemesh -I../trianglemesh/include -I../../Tools/Qt/5.2.1/clang_64/lib/QtOpenGL.framework/Versions/5/Headers -I../../Tools/Qt/5.2.1/clang_64/lib/QtWidgets.framework/Versions/5/Headers -I../../Tools/Qt/5.2.1/clang_64/lib/QtGui.framework/Versions/5/Headers -I../../Tools/Qt/5.2.1/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/zdd/Tools/Qt/5.2.1/clang_64/lib -o main.o ../trianglemesh/main.cpp


你可能感兴趣的:(Qt5.2.1 Mac 10.9 Undefined symbols for architecture x86_64 错误解决)