Building EOS with Visual Studio 2017 for Windows 10
For any Windows C++ developer used to Visual Studio IDE, you might find that currently there is no support to building the awesome EOS project with it.
So I decided to put my skills to the task and modify the source code to support it the best I can and decided to share with the community my experience.
The first thing you need to do is install visual studio 2017 with C++ and Cmake support
1 - install VS 2017 (https://www.visualstudio.com/) and add extra components
- Add component VC++
- Add component VC++ 2017 toolset v141
- Add component VC++ 2017 toolset CMAKE
- Add component MSBuild
- Add component Windows 10 SDK (10.0.16299.0)
2 - Next you need to install NASM and perl to build openssl dependency
3 - This perl module is used by the build.ps1 powershell script to uncompress tar files, run the command:
ppm install Archive-Extract
4 - Since I needed to do some modifications to the EOS source code you need to grab my fork from github
git clone https://github.com/mmcs85/eos --recursive
In order to build EOS the following dependencies where used:
- boost 1.65.1
- gettext 0.19.8
- zlib 1.2.11
- openssl 1.1.0
- mpir 3.0.0 (forked from the GMP bignum library)
- secp256k1-zkp (latest)
- binaryen (latest)
- llvm 4.0
- clang 4.0
For the build process to be easier I created a build.ps1 powershell script that builds EOS with the dependencies.
Run the simple command in powershell to build everything including EOS
For building the dependencies only and later on use the cmake build system inside visual studio, run command
.\build.ps1 -buildType dep
To check all the options you can run the command
If you see a install\bin folder with eosd and eosc congratulations you have successfully built EOS :)
Building Smart contracts
After building EOS another important part is generating smart contracts webassembly. The eoscpp bash script is installed to create smart contract templates and building their .wast, but there is not a windows version.
So I decided to create the equivalent eoscpp.ps1 powershell script to do this task.
You will find it in the install\bin folder and you can run the command to see the options
You need to build EOS in Debug mode first including dependencies.
NOTE: if you built previously just delete the extdeps and install folder first then run command
.\build.ps1 -config Debug -buildType dep
If you build EOS with the Cmake integration in visual studio you can debug from install folder any application including eosd or eosc. Also you can attach to any process as usual.
So far the big limitation I found is the usage of the uint128 data type that uses the intrisic __int128 not supporter in the MSVC compiler.
I have tried the boost uint128 version but it references std libs that is not a option for the .wast generation creating a lot of bloatware.
I'm thinking in looking into the Clang/gcc implementation but dint find the time yet.
Also had to disable related unit test using this data type.
I have learn a lot about blockchain and EOS in this adventure and I'm just scratching the surface.
Please be aware that this is a unofficial tutorial and that the support and integration on EOS is fully at their own discretion. Also I can not guaranty the correct synchronization of my fork with the eosio upstream. I will do my best to maintain it.
I'm sure EOS team as more important things to do anyways :)
Finally feel free to ask any questions.