Remix
如果你只是想嘗試用solidity編寫小的合約,你可以使用Remix, 不需要安裝。如果你想使用離線版本,可以到 https://github.com/ethereum/browser-solidity/tree/gh-pages 下載zip文件使用。
Npm/ Node.js
這是最快速,便捷的方式安裝本地Solidity.Emscripten提供了一個跨平台的js庫,可以把C++的源碼編譯成JavaScript.當然也可以在項目里直接使用(如Remix)。Solc-js可以通過npm安裝:
npm install -g solc
Docker
我們提供了最新的docker編譯,stable分支包含了release版本,而每日編譯分支可能包含不穩定的代碼。
安裝命令
docker run ethereum/solc:stable solc --version
二進制包
Ubuntu的PPAs,最新的版本
sudo add-apt-repository ppa:ethereum/ethereum sudo apt-get update sudo apt-get install solc
如果你想使用最新的開發版本:
sudo add-apt-repository ppa:ethereum/ethereum sudo add-apt-repository ppa:ethereum/ethereum-dev sudo apt-get update sudo apt-get install solc
Arch Linux也有安裝包,albeit限制了最新使用版本
pacman -S solidity-git
如果你想安裝特定版本的Solidity,可以直接通過Github安裝Homebrew。地址為:
https://github.com/ethereum/homebrew-ethereum/commits/master/solidity.rb
通過brew安裝
brew unlink solidity # Install 0.4.8 brew install https://raw.githubusercontent.com/ethereum/homebrew-ethereum/77cce03da9f289e5a3ffe579840d3c5dc0a62717/solidity.rb
通過源碼編譯
clone 代碼:
git clone --recursive https://github.com/ethereum/solidity.git cd solidity
如果你想開發Solidity,可以fork Solidity,添加自己的fork分支來進行開發
cd solidity git remote add personal git@github.com:[username]/solidity.git
Solidity有submodules,確保所有的submodules是被正確加載的。
git submodule update --init --recursive
MacOS的要求
需要安裝最新的Xcode。如果你是第一次安裝Xcode,或是已經安裝了最新版本,在使用命令行前,需要進行license授權
sudo xcodebuild -license accept
Windows的要求
需要安裝Git for Window, CMake,VS2015
我們現在提供了一鍵安裝。使用
./scripts/install_deps.sh
或是
scripts\install_deps.bat(在Windows)
命令行編譯
使用
mkdir build cd build cmake .. && make
或是更簡單的:
#note: this will install binaries solc and soltest at usr/local/bin ./scripts/build.sh
在windows系統上:
mkdir build cd build cmake -G "Visual Studio 14 2015 Win64" ..
或者可以在windows上使用命令行:
cmake --build . --config RelWithDebInfo
歡迎大家關注微信號:蝸牛講技術。掃下面的二維碼