MacOS Quick Start: Difference between revisions

From Miosix Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 35: Line 35:




=== GCC 4.9.3 installation ===
=== Packages installation ===


'''Install GNU tar'''


'''Install GCC 4.9.3'''
Running the Miosix toolchain compilation script may give you an error related to extracting a file. Therefore, using GNU tar instead of Apple tar is suggested.
 
 
Run this command in terminal to add the repository containing GNU tar to Homebrew:


Running the Miosix toolchain compilation script using Apple GCC has proven unsuccessful. That's why we need to install GCC 4.9.3 from Homebrew. Perform the steps below:
<source lang="bash">
brew tap homebrew/dupes
</source>




Run this command in terminal to grab the most recent packages list:
Run this command in terminal to grab the most recent packages list from Homebrew:


<source lang="bash">
<source lang="bash">
brew update
brew update
</source>
</source>
Run this command to install GNU tar:
<source lang="bash">
brew install gnu-tar
</source>
'''Install GCC 4.9.3'''
Running the Miosix toolchain compilation script using Apple GCC has proven unsuccessful. That's why we need to install GCC 4.9.3 from Homebrew. Perform the steps below:




Line 54: Line 72:
<source lang="bash">
<source lang="bash">
brew tap homebrew/versions
brew tap homebrew/versions
</source>
Run this command in terminal to grab the most recent packages list from Homebrew:
<source lang="bash">
brew update
</source>
</source>


Line 61: Line 86:
<source lang="bash">
<source lang="bash">
brew install gcc49
brew install gcc49
</source>
'''Symlink GCC 4.9.3 executables'''
First, you need to create appropriate symlinks within /usr/local/bin from the versioned name of gcc executables to generic ones. Run these commands from terminal:
<source lang="bash">
ln -s /usr/local/bin/gcc-4.9 /usr/local/bin/gcc
ln -s /usr/local/bin/gcc-4.9 /usr/local/bin/cc
ln -s /usr/local/bin/g++-4.9 /usr/local/bin/g++
ln -s /usr/local/bin/cpp-4.9 /usr/local/bin/cpp
ln -s /usr/local/bin/c++-4.9 /usr/local/bin/c++
</source>
Please notice that gcc-4.9 has not been symlinked to ld has someone may expect, since it has proven prone to errors during the Miosix toolchain compilation. Instead, we are gonna use Apple own Clang ld as a linker.
'''Edit PATH variable'''
Now you need to make sure that /usr/local/bin gets inspected before /usr/bin when looking for gcc, so that Homebrew GCC 4.9.3 will be called instead of Apple GCC. In order to do so, we are gonna modify the $PATH terminal variable. Run from terminal:
<source lang="bash">
cd
</source>
To get into your home folder.
Run from terminal:
<source lang="bash">
edit .bash_profile
</source>
To edit the bash profile script.
You need to add the following lines as they are:
<source lang="bash">
#homebrew gcc
export PATH=/usr/local/bin:$PATH
#gnu-tar
export PATH=/usr/local/opt/gnu-tar/libexec/gnubin:$PATH
</source>
Save and close the file.
Then run from terminal:
<source lang="bash">
source .bash_profile
</source>
in order to reload the bash profile script.
'''Check the installed packages'''
If everything went as supposed, running from terminal:
<source lang="bash">
gcc -v
</source>
should return some text including:
<source lang="bash">
gcc version 4.9.3 (Homebrew gcc49 4.9.3)
</source>
While running from terminal:
<source lang="bash">
ld -v
</source>
should return some text including:
<source lang="bash">
LTO support using: Apple LLVM 7.0.0
</source>
And finally running from terminal:
<source lang="bash">
tar --version
</source>
should return some text including:
<source lang="bash">
tar (GNU tar)
</source>
</source>

Revision as of 23:17, 21 November 2015

ATTENTION: This page is still a WIP. Usual disclaimers about not taking responsibility for your system disruption applies.

Before you begin

This procedure has been tested on OS X El Capitain 10.11. The Miosix toolchain has been successfully compiled using GCC 4.9.3, which can be installed using the Homebrew package manager.


Install Xcode

Install Xcode by downloading it from the Mac App Store here. This is needed for installing the XCode command line tools which in turn is needed by Homebrew.


Install Xcode command line tools

Install Command Line tools by running the following command in terminal.
xcode-select --install


It is recommended to run the command even if Xcode and the Command Line tools were already installed on your system, since the Command Line tools installation may have been messed up by upgrading to 10.11 from a previous release.


Install Homebrew

Grab a copy of Homebrew and run the install script in one step using this command in terminal:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


If it complains about permission issues, then you have to fix it before you can continue. In Mac OS X El Capitan 10.11, Apple introduced a new feature called System Integrity Protector (SIP), which prevents from writing to many system directories such as /usr, /System, /bin, regardless of whether or not you are root. Apple is leaving /usr/local open for developers to use, so Homebrew can still be used as expected; however, performing a few steps may be required depending on you system, as outlined in the official Homebrew documentation here.


Packages installation

Install GNU tar

Running the Miosix toolchain compilation script may give you an error related to extracting a file. Therefore, using GNU tar instead of Apple tar is suggested.


Run this command in terminal to add the repository containing GNU tar to Homebrew:

brew tap homebrew/dupes


Run this command in terminal to grab the most recent packages list from Homebrew:

brew update


Run this command to install GNU tar:

brew install gnu-tar


Install GCC 4.9.3

Running the Miosix toolchain compilation script using Apple GCC has proven unsuccessful. That's why we need to install GCC 4.9.3 from Homebrew. Perform the steps below:


Run this command in terminal to add the repository containing GCC 4.9.3 to Homebrew:

brew tap homebrew/versions


Run this command in terminal to grab the most recent packages list from Homebrew:

brew update


Run this command to install GCC 4.9.3:

brew install gcc49


Symlink GCC 4.9.3 executables

First, you need to create appropriate symlinks within /usr/local/bin from the versioned name of gcc executables to generic ones. Run these commands from terminal:

ln -s /usr/local/bin/gcc-4.9 /usr/local/bin/gcc
ln -s /usr/local/bin/gcc-4.9 /usr/local/bin/cc
ln -s /usr/local/bin/g++-4.9 /usr/local/bin/g++
ln -s /usr/local/bin/cpp-4.9 /usr/local/bin/cpp
ln -s /usr/local/bin/c++-4.9 /usr/local/bin/c++

Please notice that gcc-4.9 has not been symlinked to ld has someone may expect, since it has proven prone to errors during the Miosix toolchain compilation. Instead, we are gonna use Apple own Clang ld as a linker.


Edit PATH variable

Now you need to make sure that /usr/local/bin gets inspected before /usr/bin when looking for gcc, so that Homebrew GCC 4.9.3 will be called instead of Apple GCC. In order to do so, we are gonna modify the $PATH terminal variable. Run from terminal:

cd

To get into your home folder.


Run from terminal:

edit .bash_profile

To edit the bash profile script.


You need to add the following lines as they are:

#homebrew gcc
export PATH=/usr/local/bin:$PATH
#gnu-tar
export PATH=/usr/local/opt/gnu-tar/libexec/gnubin:$PATH

Save and close the file.


Then run from terminal:

source .bash_profile

in order to reload the bash profile script.


Check the installed packages

If everything went as supposed, running from terminal:

gcc -v

should return some text including:

gcc version 4.9.3 (Homebrew gcc49 4.9.3)


While running from terminal:

ld -v

should return some text including:

LTO support using: Apple LLVM 7.0.0


And finally running from terminal:

tar --version

should return some text including:

tar (GNU tar)