2016-08-29 17:24:28 +00:00
.. index :: ! installing
.. _installing-solidity:
2018-01-05 15:13:33 +00:00
################################
Installing the Solidity Compiler
################################
2015-12-10 11:22:53 +00:00
2016-09-08 17:44:14 +00:00
Versioning
==========
2016-10-12 08:25:17 +00:00
Solidity versions follow `semantic versioning <https://semver.org> `_ and in addition to
2016-09-08 17:44:14 +00:00
releases, **nightly development builds** are also made available. The nightly builds
are not guaranteed to be working and despite best efforts they might contain undocumented
2016-10-26 17:43:51 +00:00
and/or broken changes. We recommend using the latest release. Package installers below
2016-09-13 11:13:21 +00:00
will use the latest release.
2016-09-08 17:44:14 +00:00
2017-03-15 22:58:14 +00:00
Remix
=====
2015-12-10 11:22:53 +00:00
2018-01-05 15:13:33 +00:00
*We recommend Remix for small contracts and for quickly learning Solidity.*
`Access Remix online <https://remix.ethereum.org/> `_ , you don't need to install anything.
If you want to use it without connection to the Internet, go to
2018-08-24 07:01:54 +00:00
https://github.com/ethereum/remix-live/tree/gh-pages and download the `` .zip `` file as
2018-01-05 15:13:33 +00:00
explained on that page.
Further options on this page detail installing commandline Solidity compiler software
on your computer. Choose a commandline compiler if you are working on a larger contract
or if you require more compilation options.
2016-08-26 20:17:31 +00:00
2018-02-26 23:36:01 +00:00
.. _solcjs:
2016-05-19 17:27:57 +00:00
npm / Node.js
2015-12-10 11:22:53 +00:00
=============
2018-01-05 15:13:33 +00:00
Use `npm` for a convenient and portable way to install `solcjs` , a Solidity compiler. The
2018-09-13 21:43:10 +00:00
`solcjs` program has fewer features than the ways to access the compiler described
further down this page. The
2018-02-26 23:38:52 +00:00
:ref: `commandline-compiler` documentation assumes you are using
2018-09-13 21:43:10 +00:00
the full-featured compiler, `solc` . The usage of `solcjs` is documented inside its own
2018-09-13 14:09:48 +00:00
`repository <https://github.com/ethereum/solc-js> `_ .
2015-12-10 11:22:53 +00:00
2018-02-26 23:38:52 +00:00
Note: The solc-js project is derived from the C++
2018-09-13 14:09:48 +00:00
`solc` by using Emscripten which means that both use the same compiler source code.
`solc-js` can be used in JavaScript projects directly (such as Remix).
2018-02-26 23:38:52 +00:00
Please refer to the solc-js repository for instructions.
2015-12-10 11:22:53 +00:00
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2015-12-10 11:22:53 +00:00
2017-02-02 10:19:22 +00:00
npm install -g solc
.. note ::
2015-12-10 11:22:53 +00:00
2018-09-13 14:09:48 +00:00
The commandline executable is named `solcjs` .
2018-01-05 15:13:33 +00:00
2017-02-02 10:19:22 +00:00
The comandline options of `solcjs` are not compatible with `solc` and tools (such as `geth` )
expecting the behaviour of `solc` will not work with `solcjs` .
2015-12-10 11:22:53 +00:00
2016-11-24 22:46:37 +00:00
Docker
======
2016-11-25 15:21:17 +00:00
We provide up to date docker builds for the compiler. The `` stable ``
repository contains released versions while the `` nightly ``
repository contains potentially unstable changes in the develop branch.
2016-11-24 22:46:37 +00:00
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2016-11-24 22:46:37 +00:00
2018-07-12 22:19:41 +00:00
docker run ethereum/solc:stable --version
2016-11-24 22:46:37 +00:00
2017-08-07 11:53:56 +00:00
Currently, the docker image only contains the compiler executable,
2016-11-24 22:46:37 +00:00
so you have to do some additional work to link in the source and
output directories.
2015-12-10 11:22:53 +00:00
Binary Packages
===============
2018-01-05 15:13:33 +00:00
Binary packages of Solidity are available at
2016-08-24 20:33:59 +00:00
`solidity/releases <https://github.com/ethereum/solidity/releases> `_ .
2018-09-13 14:09:48 +00:00
We also have PPAs for Ubuntu, you can get the latest stable
version using the following commands:
2016-08-26 20:17:31 +00:00
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2016-08-26 20:17:31 +00:00
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
2018-09-13 14:09:48 +00:00
The nightly version can be installed using these commands:
2016-08-26 20:17:31 +00:00
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2016-08-26 20:17:31 +00:00
sudo add-apt-repository ppa:ethereum/ethereum
sudo add-apt-repository ppa:ethereum/ethereum-dev
sudo apt-get update
sudo apt-get install solc
2018-09-03 13:01:15 +00:00
2017-08-02 07:51:43 +00:00
We are also releasing a `snap package <https://snapcraft.io/> `_ , which is installable in all the `supported Linux distros <https://snapcraft.io/docs/core/install> `_ . To install the latest stable version of solc:
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2017-08-02 07:53:07 +00:00
2017-08-02 07:51:43 +00:00
sudo snap install solc
2018-09-13 21:43:10 +00:00
If you want to help testing the latest development version of Solidity
with the most recent changes, please use the following:
2017-07-26 16:28:27 +00:00
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2017-08-02 07:53:07 +00:00
2017-07-26 16:28:27 +00:00
sudo snap install solc --edge
2016-08-26 20:17:31 +00:00
2017-02-06 18:23:49 +00:00
Arch Linux also has packages, albeit limited to the latest development version:
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2017-02-06 18:23:49 +00:00
2017-08-27 11:36:41 +00:00
pacman -S solidity
2017-02-06 18:23:49 +00:00
2018-09-13 14:09:48 +00:00
We distribute the Solidity compiler through Homebrow
as a build-from-source version. Pre-built bottles are
currently not supported.
2016-08-26 20:17:31 +00:00
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2016-08-26 20:17:31 +00:00
brew update
brew upgrade
brew tap ethereum/ethereum
brew install solidity
2018-09-03 13:01:15 +00:00
If you need a specific version of Solidity you can install a
2017-02-21 22:45:15 +00:00
Homebrew formula directly from Github.
2018-09-03 13:01:15 +00:00
View
2017-02-21 22:45:15 +00:00
`solidity.rb commits on Github <https://github.com/ethereum/homebrew-ethereum/commits/master/solidity.rb> `_ .
2018-09-03 13:01:15 +00:00
Follow the history links until you have a raw file link of a
2017-02-21 22:45:15 +00:00
specific commit of `` solidity.rb `` .
Install it using `` brew `` :
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2017-02-21 22:45:15 +00:00
brew unlink solidity
# Install 0.4.8
brew install https://raw.githubusercontent.com/ethereum/homebrew-ethereum/77cce03da9f289e5a3ffe579840d3c5dc0a62717/solidity.rb
2015-12-10 11:22:53 +00:00
2017-06-07 22:20:15 +00:00
Gentoo Linux also provides a solidity package that can be installed using `` emerge `` :
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2017-06-07 22:20:15 +00:00
2017-08-14 19:47:16 +00:00
emerge dev-lang/solidity
2017-06-07 22:20:15 +00:00
2016-08-29 17:24:28 +00:00
.. _building-from-source:
2015-12-10 11:22:53 +00:00
Building from Source
====================
2016-08-24 20:33:59 +00:00
Clone the Repository
--------------------
To clone the source code, execute the following command:
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2016-08-24 20:33:59 +00:00
git clone --recursive https://github.com/ethereum/solidity.git
cd solidity
If you want to help developing Solidity,
you should fork Solidity and add your personal fork as a second remote:
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2015-12-10 11:22:53 +00:00
2016-08-29 18:22:52 +00:00
git remote add personal git@github.com:[username]/solidity.git
2015-12-10 11:22:53 +00:00
2017-01-17 07:14:53 +00:00
Solidity has git submodules. Ensure they are properly loaded:
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2017-01-17 07:14:53 +00:00
git submodule update --init --recursive
2015-12-10 11:22:53 +00:00
2016-08-24 20:33:59 +00:00
Prerequisites - macOS
2016-08-24 20:33:59 +00:00
---------------------
2015-12-10 11:22:53 +00:00
2016-08-24 20:33:59 +00:00
For macOS, ensure that you have the latest version of
2016-08-24 20:33:59 +00:00
`Xcode installed <https://developer.apple.com/xcode/download/> `_ .
2016-08-24 20:33:59 +00:00
This contains the `Clang C++ compiler <https://en.wikipedia.org/wiki/Clang> `_ , the
2016-08-24 20:33:59 +00:00
`Xcode IDE <https://en.wikipedia.org/wiki/Xcode> `_ and other Apple development
2016-08-24 20:33:59 +00:00
tools which are required for building C++ applications on OS X.
2016-08-24 20:33:59 +00:00
If you are installing Xcode for the first time, or have just installed a new
2016-08-24 20:33:59 +00:00
version then you will need to agree to the license before you can do
command-line builds:
2015-12-10 11:22:53 +00:00
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2015-12-10 11:22:53 +00:00
2016-08-24 20:33:59 +00:00
sudo xcodebuild -license accept
2015-12-10 11:22:53 +00:00
2016-08-24 20:33:59 +00:00
Our OS X builds require you to `install the Homebrew <http://brew.sh> `_
package manager for installing external dependencies.
Here's how to `uninstall Homebrew
<https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/FAQ.md#how-do-i-uninstall-homebrew> `_,
if you ever want to start again from scratch.
2016-05-13 14:32:35 +00:00
2015-12-10 11:22:53 +00:00
2016-08-24 20:33:59 +00:00
Prerequisites - Windows
2016-08-24 20:33:59 +00:00
-----------------------
2016-06-05 15:40:03 +00:00
2016-08-24 20:33:59 +00:00
You will need to install the following dependencies for Windows builds of Solidity:
2016-06-05 15:40:03 +00:00
2018-05-02 13:46:52 +00:00
+-----------------------------------+-------------------------------------------------------+
| Software | Notes |
+===================================+=======================================================+
| `Git for Windows`_ | Command-line tool for retrieving source from Github. |
+-----------------------------------+-------------------------------------------------------+
| `CMake`_ | Cross-platform build file generator. |
+-----------------------------------+-------------------------------------------------------+
| `Visual Studio 2017 Build Tools`_ | C++ compiler |
+-----------------------------------+-------------------------------------------------------+
| `Visual Studio 2017`_ (Optional) | C++ compiler and dev environment. |
+-----------------------------------+-------------------------------------------------------+
If you've already had one IDE and only need compiler and libraries,
you could install Visual Studio 2017 Build Tools.
Visual Studio 2017 provides both IDE and necessary compiler and libraries.
So if you have not got an IDE and prefer to develop solidity, Visual Studio 2017
may be an choice for you to get everything setup easily.
Here is the list of components that should be installed
in Visual Studio 2017 Build Tools or Visual Studio 2017:
* Visual Studio C++ core features
* VC++ 2017 v141 toolset (x86,x64)
* Windows Universal CRT SDK
* Windows 8.1 SDK
* C++/CLI support
2016-06-05 15:40:03 +00:00
2016-08-24 20:33:59 +00:00
.. _Git for Windows: https://git-scm.com/download/win
.. _CMake: https://cmake.org/download/
2018-05-02 13:46:52 +00:00
.. _Visual Studio 2017: https://www.visualstudio.com/vs/
.. _Visual Studio 2017 Build Tools: https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017
2016-08-11 20:50:27 +00:00
2016-06-05 15:40:03 +00:00
2016-08-24 20:33:59 +00:00
External Dependencies
2016-06-05 15:40:03 +00:00
---------------------
2015-12-10 11:22:53 +00:00
2018-09-13 21:43:10 +00:00
We have a helper script which installs all required external dependencies
2018-09-13 14:09:48 +00:00
on macOS, Windows and on numerous Linux distros.
2015-12-10 11:22:53 +00:00
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2015-12-10 11:22:53 +00:00
2016-08-24 20:33:59 +00:00
./scripts/install_deps.sh
2015-12-10 11:22:53 +00:00
2016-08-24 20:33:59 +00:00
Or, on Windows:
2016-08-11 20:50:27 +00:00
2018-08-09 18:04:27 +00:00
.. code-block :: bat
2016-07-11 15:23:17 +00:00
2016-08-24 20:33:59 +00:00
scripts\install_deps.bat
2015-12-10 11:22:53 +00:00
2016-08-24 20:33:59 +00:00
Command-Line Build
------------------
2015-12-10 11:22:53 +00:00
2017-10-19 05:25:27 +00:00
**Be sure to install External Dependencies (see above) before build.**
2017-08-22 14:55:54 +00:00
Solidity project uses CMake to configure the build.
2018-09-13 14:09:48 +00:00
You might want to install ccache to speed up repeated builds.
CMake will pick it up automatically.
2016-08-24 20:33:59 +00:00
Building Solidity is quite similar on Linux, macOS and other Unices:
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2015-12-10 11:22:53 +00:00
2016-08-04 09:04:13 +00:00
mkdir build
cd build
cmake .. && make
2015-12-10 11:22:53 +00:00
2017-02-03 00:00:46 +00:00
or even easier:
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2018-09-03 13:01:15 +00:00
2017-02-03 00:38:38 +00:00
#note: this will install binaries solc and soltest at usr/local/bin
2017-02-03 00:00:46 +00:00
./scripts/build.sh
2018-09-13 14:09:48 +00:00
And for Windows:
2015-12-10 11:22:53 +00:00
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2015-12-10 11:22:53 +00:00
2016-08-24 20:33:59 +00:00
mkdir build
cd build
2018-05-02 13:46:52 +00:00
cmake -G "Visual Studio 15 2017 Win64" ..
2016-08-24 20:33:59 +00:00
This latter set of instructions should result in the creation of
**solidity.sln** in that build directory. Double-clicking on that file
should result in Visual Studio firing up. We suggest building
**RelWithDebugInfo** configuration, but all others work.
Alternatively, you can build for Windows on the command-line, like so:
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2016-08-24 20:33:59 +00:00
cmake --build . --config RelWithDebInfo
2016-09-13 11:13:21 +00:00
2017-08-22 14:55:54 +00:00
CMake options
=============
If you are interested what CMake options are available run `` cmake .. -LH `` .
2018-08-08 14:46:17 +00:00
SMT Solvers
-----------
2018-09-03 13:01:15 +00:00
Solidity can be built against SMT solvers and will do so by default if
2018-08-08 14:46:17 +00:00
they are found in the system. Each solver can be disabled by a `cmake` option.
*Note: In some cases, this can also be a potential workaround for build failures.*
Inside the build folder you can disable them, since they are enabled by default:
2018-08-09 18:04:27 +00:00
.. code-block :: bash
2018-08-08 14:46:17 +00:00
# disables only Z3 SMT Solver.
2018-09-03 13:01:15 +00:00
cmake .. -DUSE_Z3=OFF
2018-08-08 14:46:17 +00:00
# disables only CVC4 SMT Solver.
cmake .. -DUSE_CVC4=OFF
# disables both Z3 and CVC4
cmake .. -DUSE_CVC4=OFF -DUSE_Z3=OFF
2017-01-17 12:32:07 +00:00
The version string in detail
============================
The Solidity version string contains four parts:
2017-03-16 00:43:25 +00:00
2017-01-17 12:32:07 +00:00
- the version number
- pre-release tag, usually set to `` develop.YYYY.MM.DD `` or `` nightly.YYYY.MM.DD ``
- commit in the format of `` commit.GITHASH ``
2018-09-13 21:43:10 +00:00
- platform, which has an arbitrary number of items, containing details about the platform and compiler
2017-01-17 12:32:07 +00:00
If there are local modifications, the commit will be postfixed with `` .mod `` .
2017-01-17 13:01:11 +00:00
These parts are combined as required by Semver, where the Solidity pre-release tag equals to the Semver pre-release
and the Solidity commit and platform combined make up the Semver build metadata.
2017-06-23 04:37:28 +00:00
A release example: `` 0.4.8+commit.60cc1668.Emscripten.clang `` .
2017-01-17 12:32:07 +00:00
A pre-release example: `` 0.4.9-nightly.2017.1.17+commit.6ecb4aa3.Emscripten.clang ``
2016-09-13 11:13:21 +00:00
Important information about versioning
======================================
After a release is made, the patch version level is bumped, because we assume that only
patch level changes follow. When changes are merged, the version should be bumped according
to semver and the severity of the change. Finally, a release is always made with the version
of the current nightly build, but without the `` prerelease `` specifier.
Example:
2016-09-23 16:27:23 +00:00
0. the 0.4.0 release is made
1. nightly build has a version of 0.4.1 from now on
2. non-breaking changes are introduced - no change in version
3. a breaking change is introduced - version is bumped to 0.5.0
4. the 0.5.0 release is made
2016-09-13 11:13:21 +00:00
2017-03-16 00:42:42 +00:00
This behaviour works well with the :ref: `version pragma <version_pragma>` .