How to build solidity on macOS
Information
Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript and it is designed to target the Ethereum Virtual Machine (EVM).
This tutorial shows how to build Solidity from source, meaning building the Solidity compiler also known as solc.
Information about Solidity, see: https://solidity.readthedocs.io/en/latest/index.html
Solidity code, see: https://github.com/ethereum/solidity
Operating system used
macOS 10.12 Sierra
Software prerequisites
Xcode
Homebrew
Procedure
- Checkout solidity from the remote git repository.
- Type: mkdir ~/tools
- Type: cd ~/tools
- Type: git clone https://github.com/ethereum/solidity.git
- Type: cd solidity
- Checkout the solidity version you want, for example v0.4.11.
- Show all local tags: git tag -l
This command shows the following:
:
v0.3.2
v0.3.3
v0.3.4
v0.3.5
v0.3.6
v0.4.0
v0.4.1
v0.4.10
v0.4.11
:
- Checkout tag v0.4.11, type: git checkout tags/v0.4.11
- Check if the correct tag is checked out, type: git branch
You should see:
* (HEAD detached at v0.4.11)
- Update submodules.
Type: cd ~/tools/solidity
Type: git submodule update
- Install all required external dependencies on macOS.
Type: cd ~/tools/solidity/scripts
Type: ./install_deps.sh
This will install several homebrew pacakges in /usr/local/Cellar/
- Building Solidity.
Type: cd ~/tools/solidity/scripts
Type: ./build.sh
it takes several minutes to build....
You will see the following:
:
[100%] Linking CXX executable soltest
[100%] Built target soltest
Installing solc and soltest
- When the build is finished, checkout the version:
Type: solc --version
You will see the following:
solc, the solidity compiler commandline interface
Version: 0.4.11-develop.2017.6.28+commit. 68ef5810.Darwin.appleclang
- The solc program is also installed in /usr/local/bin/solc.
Type: which solc to find the solc location.
There is NO need to update your ~/.bash_profile file and add the following line:
# Solidity
export PATH=$PATH:/Users/robertlie/tools/solidity/build/solc
- If you want to build another solidity version, you need to undo all changes in the solidity folder.
Type: cd ~/tools/solidity
Type: git checkout -f
Type: git clean -fd
Type: git pull and start again with step 2.
|