How do I change compiler on Xcode to gcc 7.3.0? - xcode

I currently have Xcode 6.2.
First is there a way to check if this version of Xcode comes with gcc 7.3.0? And if it does have gcc 7.3.0, how do I set up Xcode so that gcc 7.3.0 becomes the default compiler?
However if my Xcode does not have gcc 7.3.0 how do I get gcc 7.3 and set up Xcode so that gcc 7.3.0 becomes the default compiler?

Xcode uses the LLVM Clang compiler, not gcc. gcc can be installed, the easiest way would be using either Homebrew or MacPorts. I'm not sure if there's any way to make it the default compiler though, especially not to use from inside Xcode. Is there some specific feature/reason why you need gcc 7.3?

Related

How can I set gcc 4.9.2 as my compiler for Xcode 7.2

I am learning C, using my mac to code right now.
Currently I am using gcc version 4.9.2 (found by going gcc --version) on terminal. However this is when I am connected to my school server.
When I am not connected I get some random things with Xcode etc etc...
Question is in Xcode, my default compiler is Apple LLVM 7.0, and there is no option in the dropdown box to change it to a gcc compiler.
I am wondering how I can change the compiler on Xcode from LLVM to gcc...
Thanks all !

What compilers are included in Xcode Command Line tools?

Is there a way to check this? I know llvm is one of the compilers in Xcode, I think GCC also?? Is this correct? is there a definitive way to know?
From the Xcode 4 Release Notes:
DEPRECATED: LLVM-GCC compiler and GDB debugger.
Xcode 4.6 is the last release to include the LLVM-GCC compiler and the GDB debugger.
And
GCC 4.0 has been removed from Xcode 4. If your project has an explicit
Compiler Version of gcc 4.0, you need to change it in order to build
with Xcode 4.
Xcode 5 comes "only" with the LLVM compiler suite, including "clang" and "clang++".

Why can't I check my version of GCC compiler on OS X

I typed this in my terminal:
llvm-gcc --version
But what I have is this :
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix`
Am I not able to interpret this block of statements? or did I forget to enable something on my system?
Nothing is wrong. The situation is just a little confusing.
Apple no longer distributes GCC with Xcode. They now use Clang as the default (and only!) compiler on Mac OS X. cc, gcc, and clang (as well as the C++ variants, c++, g++, and clang++) are now all linked to run clang under current versions of Xcode.
The version of clang you're running is, per the --version output, 500.2.79.
If you want to install GCC as an alternative to clang, you can do so using a variety of methods, including one using Homebrew:
https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers

Building Qt 4.8.1 from src on MacOS using gcc 4.5

I have a question about building Qt SDK 4.8.1 using gcc on Mac. I need to use gcc 4.5 or higher, so I installed mp-gcc45 package using macports (so tried with mp-gcc47), selected this version of gcc, so
gcc -v
Says me that gcc version 4.5.4 (MacPorts gcc45 4.5.4_6)
So I downloaded QtSDK src from official site, configure it and there is an error at first step:
cc1plus: error: unrecognized command line option "-fconstant-cfstrings"
Maybe its stupid solution, but I remove this flags from configure file, so I get a error after make call:
g++: unrecognized option '-Xarch_x86_64'
Can you give me an advice, how to build Qt using this version of gcc?
Non-Apple gcc will never work with Qt of any version. Only Apple gcc recognizes those Apple flavored compiler options.
You are stuck with gcc 4.2 on Mac. There's no way around it.

Obtaining GCC for OSX with Developer Tools installed

I want to start working with C++0x. I see that GCC 4.7 has a fair amount of functionality available. I already have XCode 3.2 installed in /Developer
I downloaded: http://fileboar.com/gcc/snapshots/LATEST-4.7/gcc-4.7-20110528.tar.bz2
Can I somehow compile this in /opt/gcc-4.7? How do I then work with my path so I can compile with GCC 4.7 from the command-line but have OSX use the version it needs?
OSX does not need gcc to run - the Developer tools are optional. So you only need to choose between gcc's when you compile. In Xcode you chose explicitly the gcc andin Makefiles you can set $(CC) or similar to the full path.
Alternatively rename the gcc-4.7 gcc to gcc-4.7 and use that so gcc is always the Apple one.
For ease of using multiple C++ compilers I use macports (or fink or homebrew) which will compile the compilers with the correct patches and also has a port select command to switch between the C++ compilers

Resources