1. First go to download gcc5.1 Source package: https://gcc.gnu.org/
2. Installation:
./configure (can be set up here to install the directory, all files are stored in a directory, later whether it is to find or delete is very convenient, eg: my location:./configure–-prefix=/usr/local/gcc5.1_source)
Gcc5.1_source This directory needs to be built in advance.
Make (it takes about 4 hours)
Make install
The 3.MAC comes with a system that uses GCC as a soft link clang compiler instead of true GCC, using the following command to see:
Ls-al $ (dirname $ (which gcc)) | grep ' gcc\|g++\|c++ '
Enter/usr/bin/to remove all old commands, because these commands are the old version of the command link:
1. Switch 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
Directory to see if the following executable programs are available:
/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. Enter the Usr/bin directory and add a soft link:
LN–S/USR/LOCAL/GCC5.1_SOURCE/BIN/GCC GCC
ln–s/usr/local/gcc5.1_source/bin/g++ g++
Ln–s/usr/local/gcc5.1_source/bin/c++ C + +
LN–S/USR/LOCAL/GCC5.1_SOURCE/BIN/CC cc
4. Use the root account to open/etc/profile This configuration file with VI (VIM) and add the gcc5.1 library file path:
1. Switch the root account.
2.vim/etc/profile
3. Add these two sentences under path:
/usr/local/gcc5.1_source/lib
/usr/local/gcc5.1_source/bin
My path is this:
Export path=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/bin:/usr/x11/bin:/a.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/bin:/usr/ Local/gcc5.1_source/lib/bin:
5. Then Source/etc/profile.
6. Review and compile the. c/.cpp file to finish.
Use the source package to compile the installation under Mac OS X 10.10.3 GCC5.1