简体   繁体   中英

Qt 5.1 for OSX installation only includes clang_64 directory, how do I compile with macports gcc?

I want to use macports gcc 4.9 with Qt/Qt creator on OSX. The problem is that the 5.1 installation only has a clang_64 directory and no obvious gcc directory. If I set the compiler to gcc 4.9 under preferences/build & run and point Qt to use the qmake under the clang_64 directory, it automatically calls clang++ instead of the gcc executable I specified.

I'm using macports gcc instead of clang because clang requires the system libc++ to be updated and support c++11 features to use them. I'm running OSX 10.6, so from what I understand this is a no go as far as c++11 clang is concerned.

Figured out one way to do it, although it is kind of hacky (Qt creator effectively ignores its own compiler settings). Use the Qt 5.1 qmake (doesn't matter that it's in the clang_64 directory). In the .pro file, add:

QMAKE_CC = gcc-mp-4.9
QMAKE_CXX = g++-mp-4.9
QMAKE_LINK = g++-mp-4.9
QMAKE_CXXFLAGS += -std=c++11

Seems to do the trick. Please comment if there's a problem with this solution / a better solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM