3

I installed a gcc 4.8.0 in the /opt folder. I put in my PATH, so when i do a gcc/g++ -v it returns to me the 4.8.0 version. But when i go to the QT Creator and compile my program with the c++11 code (implemented in 4.3 > ) it don't compile. So i put a -v option in the QMAKE_CXXFLAGS flag. So i get:

Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2335.15~25/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2335.15~25/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

Then i tried to create another toolchain that points to the new path, it is in Custom, but i cannot use it. How can i force the QT Creator to use another compiler (in my case the GCC, but in another PATH) I want to force so the XCODE dont need to change the compiler too. Is there a way to do that?

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524
Lefsler
  • 1,738
  • 6
  • 26
  • 46

2 Answers2

4

In Qt Creator go in

Tools -> Options -> Build&Run -> Compilers

then add a new gcc compiler.

Then go into

Tools -> Options -> Build&Run -> Kits

and change the compiler in your current kit (usually called "Desktop").

You may need latest versions of Qt Creator with "kits" (available from Qt Creator 2.6).

Claudio
  • 10,614
  • 4
  • 31
  • 71
0

Recently I came across this problem too. My raspberry pi's default gcc version is 8.3.0, and it doesn't support c++'s include<execution>. I downloaded another version of gcc, which is gcc-9.1.0, and it’s location is \opt\gcc-9.1.0. I've tired to add this new compiler in Tools-> Options -> Build&Run -> Compilers and change settings in kits. When I used qmake to first generate the makefile, I noticed that it's cxx flag is still gcc in make file. When I built the project, the compiler output starts with g++ -o .... not g++-9.1 -o ....

I fixed it with the following approach:

Add QMAKE_CXX = g++-9.1 -std=c++2a in your xxx.pro file. After this, when you generate makefile again, you can see that CXX in makefile is set to g++-9.1 -std=c++2a. It will use g++-9.1 when you build the project.

Ruli
  • 2,592
  • 12
  • 30
  • 40