Building EOS with Visual Studio 2017 for Windows 10

in #eos6 years ago

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.

Prerequisites

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

Building

In order to build EOS the following dependencies where used:

  • boost 1.65.1
  • gettext 0.19.8
  • zlib 1.2.11
  • bzip2-1.0.6
  • 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

.\build.ps1 

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

.\build.ps1 -help

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

.\eoscpp.ps1 -help

Debugging

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.

Limitations

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.

Conclusion

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.

Regards

Sort:  

Noob here I was going to see if it would be possible to go into more depth about the building process I'm a little confused as to how you set up your PowerShell script. I keep getting an error when i run the .\build.ps1 command... :(

Hi, can you please post the error detail in github issues?
https://github.com/mmcs85/eos/issues

Thanks

I wouldn't be posting here if I hadn't already done this.

Congratulations @mmcs! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published your First Post

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Congratulations @mmcs! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Amazing!
Now lots of Visual Studio/Windows developers can work in EOS dapps. Going to try this solution.
Seems better than the other solution here: https://steemit.com/eos/@tokenika/installing-and-running-eos-on-windows

Where is the github repo and powershell script?