solidity/docs/installing-solidity.rst

183 lines
5.3 KiB
ReStructuredText
Raw Normal View History

2015-12-10 11:22:53 +00:00
###################
Installing Solidity
###################
Browser-Solidity
================
If you just want to try Solidity for small contracts, you
2016-05-20 10:52:32 +00:00
can try `browser-solidity <https://ethereum.github.io/browser-solidity>`_
2015-12-10 11:22:53 +00:00
which does not need any installation. If you want to use it
without connection to the Internet, you can go to
https://github.com/ethereum/browser-solidity/tree/gh-pages and
download the .ZIP file as explained on that page.
2015-12-10 11:22:53 +00:00
2016-05-19 17:27:57 +00:00
npm / Node.js
2015-12-10 11:22:53 +00:00
=============
This is probably the most portable and most convenient way to install Solidity locally.
A platform-independent JavaScript library is provided by compiling the C++ source
2016-05-19 17:27:57 +00:00
into JavaScript using Emscripten for browser-solidity and there is also an npm
2015-12-10 11:22:53 +00:00
package available.
To install it, simply use
.. code:: bash
2015-12-10 11:22:53 +00:00
npm install solc
2016-05-19 17:27:57 +00:00
Details about the usage of the Node.js package can be found in the
2016-05-20 10:52:32 +00:00
`solc-js repository <https://github.com/ethereum/solc-js>`_.
2015-12-10 11:22:53 +00:00
Binary Packages
===============
Binary packages of Solidity available at
`solidity/releases <https://github.com/ethereum/solidity/releases>`_.
We also have PPAs for Ubuntu. For the latest stable version.
.. code:: bash
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
If you want to use the cutting edge developer version:
.. code:: bash
sudo add-apt-repository ppa:ethereum/ethereum
sudo add-apt-repository ppa:ethereum/ethereum-dev
sudo apt-get update
sudo apt-get install solc
Homebrew is missing pre-built bottles at the time of writing,
following a Jenkins to TravisCI migration, but Homebrew
should still work just fine as a means to build-from-source.
We will re-add the pre-built bottles soon.
.. code:: bash
brew update
brew upgrade
brew tap ethereum/ethereum
brew install solidity
brew linkapps solidity
2015-12-10 11:22:53 +00:00
Building from Source
====================
Clone the Repository
--------------------
To clone the source code, execute the following command:
.. code:: bash
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:
.. code:: bash
2015-12-10 11:22:53 +00:00
cd solidity
git remote add personal git@github.com:[username]/solidity.git
2015-12-10 11:22:53 +00:00
Prerequisites - macOS
----------------------
2015-12-10 11:22:53 +00:00
For macOS, ensure that you have the latest version of
`xcode installed <https://developer.apple.com/xcode/download/>`_.
This contains the `Clang C++ compiler <https://en.wikipedia.org/wiki/Clang>`_, the
`xcode IDE <https://en.wikipedia.org/wiki/Xcode>`_ and other Apple development
tools which are required for building C++ applications on OS X.
If you are installing xcode for the first time, or have just installed a new
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
.. code:: bash
2015-12-10 11:22:53 +00:00
sudo xcodebuild -license accept
2015-12-10 11:22:53 +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
Prerequisites - Windows
------------------------
You will need to install the following dependencies for Windows builds of Solidity:
+------------------------------+-------------------------------------------------------+
| Software | Notes |
+==============================+=======================================================+
| `Git for Windows`_ | Command-line tool for retrieving source from Github. |
+------------------------------+-------------------------------------------------------+
| `CMake`_ | Cross-platform build file generator. |
+------------------------------+-------------------------------------------------------+
| `Visual Studio 2015`_ | C++ compiler and dev environment. |
+------------------------------+-------------------------------------------------------+
.. _Git for Windows: https://git-scm.com/download/win
.. _CMake: https://cmake.org/download/
.. _Visual Studio 2015: https://www.visualstudio.com/products/vs-2015-product-editions
2016-08-11 20:50:27 +00:00
External Dependencies
---------------------
2015-12-10 11:22:53 +00:00
We now have a "one button" script which installs all required external dependencies
on macOS, Windows and on numerous Linux distros. This used to be a multi-step
manual process, but is now a one-liner:
2015-12-10 11:22:53 +00:00
.. code:: bash
2015-12-10 11:22:53 +00:00
./scripts/install_deps.sh
2015-12-10 11:22:53 +00:00
Or, on Windows:
2016-08-11 20:50:27 +00:00
.. code:: bash
2016-07-11 15:23:17 +00:00
scripts\install_deps.bat
2015-12-10 11:22:53 +00:00
Command-Line Build
------------------
2015-12-10 11:22:53 +00:00
Building Solidity is quite similar on Linux, macOS and other Unices:
.. code:: 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
And even on Windows:
2015-12-10 11:22:53 +00:00
.. code:: bash
2015-12-10 11:22:53 +00:00
mkdir build
cd build
cmake -G "Visual Studio 14 2015 Win64" ..
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:
.. code:: bash
cmake --build . --config RelWithDebInfo