Change compiler in Qt Creator on Mac OS X
-
I want to switch to the latest version of gcc and use it in Qt Creator.
- I followed the standard online installation of Qt 5.1.1 for Mac (installed in /Applications/Qt)
- Latest version of gcc has been installed using "Fink":http://fink.thetis.ig42.org (gcc 4.8.1)
- In Qt Creator, I added a new Kit, pointing to the new compiler (located in /sw/bin/gcc-4) and the installed Qt version (Qt 5.1.1 clang 64bit).
Everything looks good config-wise but when I want to compile my project, Qt Creator uses another compiler instead of the specified one:
/Applications/Xcode.app/Contents/Developer/usr/bin/g++
which corresponds to the one shipped with Xcode (llvm-g++-4.2)
Did I miss something?
-
Does your project use the new kit?
Just out of curiosity: why don't you want the clang compiler?
-
You are either not using the right kit, or maybe you need to modify the mkspecs for Qt.
-
Yes, I switched to the new kit before building the project. The compile output is different from the one generated by the clang-based kit but I still don't understand why the new kit doesn't use /sw/bin/gcc-4.
- compile output with clang based kit:
@/Applications/Qt/5.1.1/clang_64/bin/uic /Users/sylvain/Documents/Work/Dev/Qt\ projects/UITest1/mainwindow.ui -o ui_mainwindow.h
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -Wall -W -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/Applications/Qt/5.1.1/clang_64/mkspecs/macx-clang -I/Users/sylvain/Documents/Work/Dev/Qt\ projects/UITest1 -I/Applications/Qt/5.1.1/clang_64/include -I/Applications/Qt/5.1.1/clang_64/include/QtWidgets -I/Applications/Qt/5.1.1/clang_64/lib/QtWidgets.framework/Versions/5/Headers -I/Applications/Qt/5.1.1/clang_64/include/QtGui -I/Applications/Qt/5.1.1/clang_64/lib/QtGui.framework/Versions/5/Headers -I/Applications/Qt/5.1.1/clang_64/include/QtCore -I/Applications/Qt/5.1.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/Applications/Qt/5.1.1/clang_64/lib -o main.o /Users/sylvain/Documents/Work/Dev/Qt\ projects/UITest1/main.cpp@- compile output for gcc-4 based kit:
@/Applications/Qt/5.1.1/clang_64/bin/uic /Users/sylvain/Documents/Work/Dev/Qt\ projects/UITest1/mainwindow.ui -o ui_mainwindow.h
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -c -pipe -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -Wall -W -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/Applications/Qt/5.1.1/clang_64/mkspecs/macx-g++ -I/Users/sylvain/Documents/Work/Dev/Qt\ projects/UITest1 -I/Applications/Qt/5.1.1/clang_64/include -I/Applications/Qt/5.1.1/clang_64/include/QtWidgets -I/Applications/Qt/5.1.1/clang_64/lib/QtWidgets.framework/Versions/5/Headers -I/Applications/Qt/5.1.1/clang_64/include/QtGui -I/Applications/Qt/5.1.1/clang_64/lib/QtGui.framework/Versions/5/Headers -I/Applications/Qt/5.1.1/clang_64/include/QtCore -I/Applications/Qt/5.1.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/Applications/Qt/5.1.1/clang_64/lib -o main.o /Users/sylvain/Documents/Work/Dev/Qt\ projects/UITest1/main.cpp@How do I modify the mkspecs for Qt?
-
Qt has a folder named "mkspecs" somewhere, you go there and look for a toolkit similar to yours (like macx-g++), copy it, then open the files inside (they are simple Makefiles) and update the commands to point to the compiler you want to use.
I am compiling Qt myself, so this is all easy, I don't know where does the binary installer put that directory.
-
Thanks sierdzio. I've located mkspecs folder, which is in /Applications/Qt/clang_64.
This is where I'm getting confused about the role of these subfolders. I though specifying the compiler in the Qt build & run tab was enough to tell Qt how to build the project. How these mkspecs files are used in the build process?
I guess in my case, Qt is switching to the 'unsupported' config, as the one associated with my new toolchain is not present, isn't it?
-
Normally, Qt Creator should override the default setup and use whatever you have specified in your Kits. Since you are suing a custom compiler, however, I think it might be causing problems. I don't really know, though. It should work.
mkspecs are normally used when building from command line.