qt for mac工程设置相关

http://blog.csdn.net/zddblog/article/details/25872473

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

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

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

[html]  view plain  copy
 
  1. macx:QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9  
  2. macx:QMAKE_MAC_SDK=macosx10.9  


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

[html]  view plain  copy
 
  1. Release:  
  2.   
  3.   
  4. /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  
  5.   
  6. Debug:  
  7.   
  8. /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  

http://socol.iteye.com/blog/1820195

  1. macx{  
  2.     QMAKE_CFLAGS_X86_64 += -mmacosx-version-min=10.7  
  3.     QMAKE_CXXFLAGS_X86_64 = $$QMAKE_CFLAGS_X86_64  
  4.     msgpacklib.path = Contents/Frameworks  
  5.     msgpacklib.files = ../myapp/3rd/msgpack-0.5.4/src/.libs/libmsgpack.3.dylib  
  6.     evlib.path = Contents/Frameworks  
  7.     evlib.files = ../myapp/3rd/libev-4.11/.libs/libev.4.dylib  
  8.     QMAKE_BUNDLE_DATA += msgpacklib evlib  
  9.     QMAKE_POST_LINK = install_name_tool -change /usr/local/lib/libmsgpack.3.dylib \  
  10.          @executable_path/../Frameworks/libmsgpack.3.dylib \  
  11.          myapp.app/Contents/MacOs/myapp & \  
  12.          install_name_tool -change /usr/local/lib/libev.4.dylib \  
  13.          @executable_path/../Frameworks/libev.4.dylib \  
  14.          myapp.app/Contents/MacOs/myapp  

你可能感兴趣的:(qt,for,Mac)