Use the source code package in Mac OS X 10.10.3 to compile and install GCC5.1

Source: Internet
Author: User

Use the source code package in Mac OS X 10.10.3 to compile and install GCC5.1

Use the source code package in Mac OS X 10.10.3 to compile and install GCC5.1

1. First download the gcc5.1 source package: https://gcc.gnu.org/

2. installation:

. /Configure (you can set the installation directory here and store all the files in one directory. It will be convenient to search for or delete them later. For example: My location :. /configure -- prefix =/usr/local/gcc5.1 _ source)

The gcc5.1 _ source directory needs to be created in advance.

Make (about 4 hours)

Make install

3. By default, gcc is soft-linked to the clang compiler in the built-in Mac system, instead of the real gcc. You can see through the following command:

Ls-al $ (dirname $ (which gcc) | grep 'gcc \ | g ++ \ | c ++'


Go to/usr/bin/and delete all old commands, because these commands are the old command links:
1. Switch to the root account: sudo su-
2. rm/usr/bin/gcc
Rm/usr/bin/g ++
Rm/usr/bin/c ++
Rm/usr/bin/cpp
Rm/usr/bin/cc

3. Enter/usr/local/gcc5.1 _ source/bin.

Check whether the following executable programs exist in the directory:
/Usr/local/gcc5.1 _ source/bin gcc

/Usr/local/gcc5.1 _ source/bin g ++

/Usr/local/gcc5.1 _ source/bin c ++

/Usr/local/gcc5.1 _ source/bin cc

4. Go to the usr/bin directory and add the soft link:

Ln-s/usr/local/gcc5.1 _ source/bin/gcc

Ln-s/usr/local/gcc5.1 _ source/bin/g ++

Ln-s/usr/local/gcc5.1 _ source/bin/c ++

Ln-s/usr/local/gcc5.1 _ source/bin/cc

 

4. Use the root account to use vi (vim) to open the/etc/profile configuration file and add the library file path of gcc5.1:

1. Switch to the root account.
2. vim/etc/profile
3. Add the following two sentences in the PATH:
/Usr/local/gcc5.1 _ source/lib

/Usr/local/gcc5.1 _ source/bin

My PATH is like this:
Export PATH =/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin:/. out/bin:/usr/local/cellar/mariadb/10.0.17/bin/mysql/bin:/usr/local/cellar/mariadb/10.0.17/bin/mysqld/bin: /usr/local/gcc5.1 _ source/bin:/usr/local/gcc5.1 _ source/lib/bin:

5. Then source/etc/profile.
6. View and compile the. c/. cpp file.

Linux GCC 4.8.1 clear and concise tutorial (Ubuntu 12.04 64-bit edition as an example)

Compile and install GCC 4.8.1 + GDB 7.6.1 + Eclipse in CentOS 6.4 and compile and install GCC 4.8.1 + GDB 7.6.1 + Eclipse in CentOS 6.4

Install and use Vim + GCC + GDB in Ubuntu

Switch two GCC versions in Ubuntu

CentOS6.5 upgrade to manually install GCC4.8.2

GCC details: click here
GCC: click here

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.