Skip to content

Commit

Permalink
Update windows instructions with alternative instructions using vcpkg
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisdral committed Jul 6, 2022
1 parent 21210c0 commit aa56d38
Showing 1 changed file with 65 additions and 19 deletions.
84 changes: 65 additions & 19 deletions doc/getting-started/building-the-node-on-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ghcup set cabal 3.6.2.0
```

## Install MSYS2 and basic dependencies

### GHCUP and MSYS2
Note that the GHCUP comes with its own installation for MSYS2, and it can be used to build `cardano-node`. You can start the MSYS2 shell with
Expand All @@ -33,37 +33,75 @@ source shell mingw64
```
The MSYS2 shell is bundled with `pacman` package manager.
The MSYS2 shell is bundled with `pacman` package manager. `GHC` is bundled with `gcc` for `mingw`. Configure your environment to use this tool-chain.
```bash
pacman -Syu
pacman -S --needed base-devel automake git
export PATH=$PATH:/mingw64/bin:<ghcup-path>/bin:<ghcup-path>
export PATH=$PATH:/mingw64/bin:<ghcup-path>/bin:<ghcup-path>/ghc/<ghc-version>/mingw/bin
```
You can update the `mingw64` toolchain, that add number of packages including latest `gcc`.
Alternatively, you can update the `mingw64` tool-chain, that adds number of packages including latest `gcc`. This may give rise to `crt` linker error. Please read the [section - global cabal configuration](#global-cabal-configuration) to mitigate the error.
```bash
pacman -S mingw-w64-x86_64-toolchain
```

### Installing MSYS independently

Go to [the MSYS2 website](https://www.msys2.org/) and follow its instructions to install MSYS2. It will also install `pacman`. Then, update and upgrade all `pacman` packages and install basic dependencies:
```
pacman -Syu
pacman -S --needed base-devel mingw-w64-x86_64-toolchain git
```

## Install Libsodium and LMDB

```
pacman -S mingw-w64-x86_64-libsodium
pacman -S mingw-w64-x86_64-lmdb
```

## Install Secp256k1
## Installing and configuring third party libraries
You can use `vcpkg`, or `pacman` or both to install third party libraries. Following are the dependencies for `cardano-node`.

| package | `vcpkg` | `pacman` | Remarks
|-----------|-----------|----------------------------|--------------------------------------
| libsodium | libsodium | mingw-w64-x86_64-lmdb |
| lmdb | lmdb | mingw-w64-x86_64-libsodium |
| secp256k1 | secp256k1 | __not available__ | `vcpkg` package is not complete.
| openssl | openssl | mingw-w64-x86_64-openssl |
|-----------|-----------|----------------------------|--------------------------------------

### Using __vcpkg__
- Install `vcpkg` for MSYS2 with instruction given [here](https://vcpkg.io/en/docs/users/mingw.html)
- Set following variables for installing libraries
```bash
export VCPKG_DEFAULT_TRIPLET=x64-mingw-static
export VCPKG_DEFAULT_HOST_TRIPLET=x64-mingw-dynamic
```
- You can also use `x64-mingw-dynamic` for `VCPKG_DEFAULT_TRIPLET`, if you'd like to use shared libraries
- Install libraries
```bash
vcpkg install libsodium
vcpkg install openssl
vcpkg install lmdb
```
- __cardano-crypto-class__ uses several features of `secp256k1` that are not compiled into `vcpkg` package. Hence it needs to be compiled separately.
- `vcpkg` generates `pkg-config` when it can. It generates configuration for `openssl`. To avoid mixing configurations with existing system, you can use following to install packages
```bash
PATH="${PATH/:\/usr\/bin:\/bin:/:}:/ming64/bin" ./vcpkg.exe install <pkg-name>
```
+ Note that packages will be generated at `<vc-pkg>/installed/${VCPKG_DEFAULT_TRIPLET}/lib/pkgconfig`.

### Using __MSYS2 pacman__

You can search for packages [here](https://packages.msys2.org/)

- Install dependencies as below
```bash
pacman -S mingw-w64-x86_64-libsodium
pacman -S mingw-w64-x86_64-lmdb
pacman -S mingw-w64-x86_64-openssl
```

### Install Secp256k1

You can use `secp256k1` either by downloading from hydra. Or by downloading from [github](https://github.com/bitcoin-core/secp256k1)

```
pacman -S unzip
Expand All @@ -78,6 +116,13 @@ If `unzip` complains that `../secp256k1.zip` is not a zip file, unzip the
file manually in the explorer by choosing the option to unzip from the
right-click menu.

### Managing package configuration
Make sure that package configurations are correectly installed. If you are using chocolatey or other tool, it may be possible that more than one `pkg-config` tools are installed. You are encouraged to use `pkg-config` that __MSYS2__ has to minimize the error. Also make sure that the pkg configuration are discoverable by checking that `pkg-config --list-all` lists all the installed packages.
Note that the pkg-config will only look in the paths pointed to by `pkg-config --variable pc_path pkg-config`. Also check if pkg-config correctly displays library path, by checking `pkg-config --variable libdir <pkg-name>`. In case, the path is incorrectly displayed, modify the file `pkg-config --path <pkg-name>` to correct the path.



## Global `cabal` configuration

Modify the following entries to your global `cabal` config file in your
Expand Down Expand Up @@ -122,9 +167,10 @@ Add the following to the `cabal.project.local` file (if you don't already have i

```
package lmdb
extra-lib-dirs: "C:\\msys64\\mingw64\\lib"
extra-include-dirs: "C:\\msys64\\mingw64\\include"
extra-lib-dirs: "<lmdb-library-path> Or standard path E.g. C:\\msys64\\mingw64\\include or C:/tools/ghcup/msys64/mingw64/lib"
extra-include-dirs: "<lmdb-library-path> Or standard path E.g. C:\\msys64\\mingw64\\include or C:/tools/ghcup/msys64/mingw64/include"
-- If pkg-config is available, use it.
package HsOpenSSL
flags: +use-pkg-config
Expand All @@ -147,9 +193,9 @@ You can now verify whether the node runs:
```bash
cabal run --builddir /c/dist exe:cardano-node -- run --help
```

## Notes

### Speed up compilation

`reorder-goals` can affect the compilation time negatively. You can disable `reorder-goals` by setting it to `False` in `cabal.project.local`.

0 comments on commit aa56d38

Please sign in to comment.