1. 程式人生 > >Qt5.2.1 Mac 10.9 Undefined symbols for architecture x86_64 錯誤解決

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