http://blog.csdn.net/zddblog/article/details/25872473
更新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
http://socol.iteye.com/blog/1820195
- macx{
- QMAKE_CFLAGS_X86_64 += -mmacosx-version-min=10.7
- QMAKE_CXXFLAGS_X86_64 = $$QMAKE_CFLAGS_X86_64
- msgpacklib.path = Contents/Frameworks
- msgpacklib.files = ../myapp/3rd/msgpack-0.5.4/src/.libs/libmsgpack.3.dylib
- evlib.path = Contents/Frameworks
- evlib.files = ../myapp/3rd/libev-4.11/.libs/libev.4.dylib
- QMAKE_BUNDLE_DATA += msgpacklib evlib
- QMAKE_POST_LINK = install_name_tool -change /usr/local/lib/libmsgpack.3.dylib \
- @executable_path/../Frameworks/libmsgpack.3.dylib \
- myapp.app/Contents/MacOs/myapp & \
- install_name_tool -change /usr/local/lib/libev.4.dylib \
- @executable_path/../Frameworks/libev.4.dylib \
- myapp.app/Contents/MacOs/myapp
- }