Gcc для mac os

How to install gcc compiler on Mac OS X

By mkyong | Last updated: August 29, 2012

Viewed: 400,908 (+568 pv/w)

Often times, you need c or gcc compiler to compile open source projects in Mac OS X. The problem is Mac OS X doesn’t install the gcc compiler by default.

If you try to install or compile some projects that required c/gcc compiler, following errors message will be logged :

In terminal, type “ gcc “, you will get message “command not found”.

Solution

To install gcc compiler on Mac OS X, you need to download and install “Command Line Tools for Xcode”, which is available in Apple’s developer page. See following steps :

1. Register Apple Developer Account

Access Apple’s developer page, to process on the download, you need to register an Apple account, it’s free, but need to spend few minutes to fill in the survey.

2. Command Line Tools for Xcode

In Apple developer page, “Developer Tools” category, find “Command Line Tools for Xcode“, choose your version and click on the xx.dmg file (file size is 100mb ++) to start the download.

3. Installation

After .dmg file is downloaded, a small dialog will be prompted and show you this file – “Command Line Tools.mpkg“, just double click on it, follow the wizard guide to complete the installation.

4. Verification

After installation is completed, run “ gcc -v ” in terminal again. If everything fine, following output will be displayed.

Done, the gcc version 4.2.1 is installed on Mac OS X successfully.

Источник

jagger27 / gcc-on-osx.md

Compiling and Running C on Mac OS X Yosemite

If you’re like me, you find working on the provided Ubuntu VM to be tortuous and inefficient. It’s such a shame to be running an operating system with all of the tools to you need to compile and run simple toy C programs but being forced to use a clunky virtual machine without all your favourite software. Here’s what I do to ease the pain.

This guide was tested on Mac OS X 10.10 Yosemite, but should also work on any version of OS X that Homebrew supports. It should work just fine on Mavericks, plus you get access to valgrind. (valgrind hasn’t been ported to 10.10 yet, but it does work on 10.9)

By default, if you have Xcode installed, typing gcc into Terminal.app links to the llvm/clang compiler. Although clang is a great, modern compiler it isn’t what’s specified by the professor and could potentially lead to incompatible code (and lost marks). To avoid this, we can install and run the same (*a slightly newer) version of gcc natively on our Macs.

Читайте также:  Что такое windows live id для нокиа

If you don’t already have Homebrew installed, go ahead and do that now. For those of you familiar with Linux package managers, Homebrew is essentially Aptitude (apt-get) for OS X.

The installer will guide you through installing any missing dependencies you may have. (Commonly Xcode tools)

Once Homebrew is installed, brew install gcc

And that’s pretty much it. But you have to watch out; gcc is actually just clang plus some extra libraries, you need to run gcc-4.9 instead.

Notice how gcc -v spits out something like

Which, clearly, isn’t what we want. Notice the slight difference between clang -v and gcc -v .

Whereas gcc-4.9 -v should show something like

Note: if gcc-4.9 isn’t being found, try opening a new shell. The $PATH sources need to be refreshed.

It’s probably a bad idea to alias gcc to gcc-4.9 because some programs (Homebrew included) may expect clang. Instead, I suggest using Makefiles to easily specify your compiler.

ALWAYS test your code in the provided VM before submitting! You have been warned.

Another option is just to use what’s included with your system. llvm/clang is a very capable, modern compiler and can, for the most part, compile the exact same code that works in gcc, at least in the scope of COMP 2401.

gcc (clang) appears to compile everything as C++ code, so you’ll probably get some weird warnings that you otherwise wouldn’t have seen. Fortunately, I’ve found that fixing things for clang tends to keep gcc-4.9 happy.

Источник

GCC for Mac

Review

Free Download

specifications

A comprehensive and useful compiler system that comes with in-built front-ends and libraries designed to support a wide variety of programming languages

What’s new in GCC 11.2.0:

  • Caveats:
  • The default mode for C++ is now -std=gnu++17 instead of -std=gnu++14. Note that C++17 changes to template template parameter matching can be disabled independently of other features with -fno-new-ttp-matching.
  • When building GCC itself, the host compiler must now support C++11, rather than C++98. In particular bootstrapping GCC 11 using an older version of GCC requires a binary of GCC 4.8 or later, rather than of GCC 3.4 or later as was the case for bootstrapping GCC 10.

Read the full changelog

The GNU Compiler Collection or GCC for short, comprises front ends for C, Objective-C, C++, Java, Fortran, Go and Ada, along with libraries for the mentioned languages.

GCC us the main component of the GNU toolchain, it is distributed under the GNU General Public License and plays a central role in the continuous growth of free software.

Take advantage of the support for numerous programing languages

Initially, GCC handled only the C programming language, but with the development of additional front ends, GCC expanded to compile C++, Objective-C, Objective-C++, Go, Fortran, Ada, Java and others.

GCC also offers support for a wide variety of processor architectures and, as a result, it is frequently used as a development tool for both free and proprietary apps. GCC is also available for most embedded platforms, including AMCC, Symbian and Freescale Power Architecture-based chips.

Compatible with various processor architectures

The GNU Compiler Collection also targets various platforms, such as video game consoles like Dreamcast and PlayStation. Moreover, GCC is the standard compile for numerous Unix-like operating systems, including Linux and the BSD family, FreeBSD and LLVM system.

Читайте также:  Windows 10 and geforce 6600 gt

Thanks to GCC’s Link-time optimization feature it optimizes across object file boundaries in order to improve the linked binary. Link-time is based on intermediate files containing the serialization of various Gimple representation present in the object file.

Expandable through plugins

Moreover, the use of plugins enables you to extend the GCC compiler and modify stock compilers to fit specific needs by loading external codes as plugins. As follows, you can use plugins to add, remove and replace middle-end passes operating on Gimple representations.

Detailed installation instructions along with the provided documentation are available on GCC’s Installation webpage.

In conclusion, GCC is a comprehensive collection of libraries and front ends that enable you to compile source code into binary application.

Источник

Mac OS X: Install GCC Compiler with Xcode

I have Mac OS X Mountain Lion. I need to compile a few apps and Perl modules. I already installed Xcode from app store but I’m unable to find gcc compiler or make command. How do I install gcc on Mac OS X 10.8.x?

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Mac OS X Mountain Lion
Est. reading time Depends on the internet speed

Xcode includes command line development tools such as gcc and friends.

Step #1: Install Xcode on a Apple Mac OS X

First, make sure Xcode is installed. If it is not installed on OS X, visit app store and install Xcode.

Fig.01: Make sure Xcode developer tools are install OS X

Step #2: Install gcc/LLVM compiler on OS X

Once installed, open Xcode and visit:

Xcode menu > Preferences > Downloads > choose » Command line tools » > Click » Install » button:

Fig.02: Installing gcc compiler on Mac OS X

Step #3: Verification

Open a terminal app and type the following commands:
$ gcc —version
$ whereis gcc
$ whereis make
Sample outputs:

Fig.03: Verify gcc compiler installation on Mountain Lion OS X

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Testing sample “Hello world” C program

Create a text file called a.c as follows using a text editor such as vi or cat command:

To compile, enter:
$ make a
Run it as follows:
$ ./a
Sample outputs:

Fig.04: Compiling and running sample “Hello world” C program on Mountain Lion 10.8.4

See also

And, there you have it, the gcc version 4.2.1 installed and working correctly on the latest version of Mac OS X 10.8.4. In Apple’s version of GCC, both cc and gcc are actually symbolic links to the llvm-gcc compiler. Similarly, c++ and g++ are links to llvm-g++. For more information and examples see the following man pages:

$ man gcc $ man make

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

There is no need to install huge xcode consumes gigabytes of disk space (if you are not a apple developer), just go to the apple’s developer page and download the “command line tool for xcode” package and install it, that would be just sufficient.

Isn’t GCC is LLVM with GCC support and many automake, m4 etc… project is not enable to build.

thank u very very very much you are really clever

THANK YOU SO MUCH. Everything else I tried didn’t seem to work. Finally this did.

Thank you very much. It worked.

I installed the Xcode Command Line Tools, and when I try to find gcc in the terminal
tell me this:

asaffeldman$ $gcc –version
-bash: –version: command not found

with 2 dashes and no $ in front of it
hope it helps!

Clear , efficient , thanks !

I have GCC 4.8.1 with x86, x86_64 and PPC on Lion with ObjC, C/C++11, Fortan, Ada Go support.
And now I can compile PHP, WxWidgets, QT and many other source without problems like on Apple Clang vesion. In xcode too.
Gcc builded with llvm-gcc-4.2.

i m doing the c programming on terminal my keyword is not highlited by compiler,
strstr function is not working why plz resolve my problm

hi
when I typed make a I got this message:
make: *** No rule to make target `a’. Stop.

please help me.
Thanks.

I got the same error when I didn’t spell the filename with the exact case.

Hi , I installed xcode and command line tools just as you said but when I try the command gcc –version I get this error
Error: could not stat active Xcode path ‘/Volumes/Xcode/Xcode.app/Contents/Developer’. (No such file or directory)

Is my xCode in the wrong place? It’s installed and under Applications, please help

I AM GETTING THIS ERROR IN XCODE WHILE I AM BUILDING A PROGRAM IN C++

I don’t have the Command Line option in my preference. Help!

Источник

Читайте также:  Не найдена hal dll windows
Оцените статью