Skip to content

Commit

Permalink
Merge pull request #29 from gorazdko/build_on_windows
Browse files Browse the repository at this point in the history
Build on windows
  • Loading branch information
wolfmcnally authored Sep 17, 2020
2 parents 4e8f0f6 + c7a531d commit 4bacb67
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
SHELL := /bin/bash
else ifeq ($(findstring MINGW64, $(UNAME)), MINGW64)
# on windows building with msys2/mingw64
SHELL := /bin/bash
endif

# Package-specific substitution variables
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ $ export CC="clang-10" && export CXX="clang++-10" && ./build.sh
$ sudo make install
```

### Windows

See [instructions here](Windows.md).

## Alternative Installation

This sequence does *not* install the dependencies from submodules; instead they must be installed in the usual places on the build system, otherwise the `./configure` step below will fail.
Expand Down
71 changes: 71 additions & 0 deletions Windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
## Seedtool on Windows

### Abstract

This document describes building `seedtool` with `MSYS2` and its usage on `Windows 10` 64-bit.

### Installing MSYS2 and Packages

* First, install `MSYS2` by downloading the installer and following the installation guide in [www.msys2.org](www.msys2.org).

* Run `MSYS2` and make sure the package database is updated:

```bash
# pacman -Syu
# pacman -Su
```

* Next, install the compiler and the required packages:

```bash
# pacman -S mingw-w64-x86_64-clang
# pacman -S patch
# pacman -S git
# pacman -S make
# pacman -S mingw-w64-x86_64-libc++
# pacman -S autoconf
# pacman -S automake1.8
```

### Compiling

First, clone `bc-seedtool-cli`, e.g. into `C:\msys64\home`, open `MSYS2 MinGW 64-bit` application and `cd` into `C:\msys64\home\bc-seedtool-cli`

* Now, run the build script with:

```bash
# export CC="clang" && export CXX="clang++" && ./build.sh
```

* and install:

```bash
# make install
```

You can now freely use `seedtool` inside `MSYS2 MinGW 64-bit` console.


### Running Seedtool as a Native Windows App

To be able to use `seedtool` as a native app on Windows outside `msys2/mingw64`, you have to expose 3 files to the system: `seedtool.exe`, `libc++.dll` and `libunwind.dll` which all reside in `C:\msys64\mingw64\bin`. So go ahead and add that folder to the `Windows PATH` by the following command in `Windows Cmd`:

```bash
set PATH=%PATH%;C:\msys64\mingw64\bin
```

That's it. Now you can use `seedtool` as a native Windows app in the Windows command line tool.


*Note:* If you want to pipe seedtool ouput into a QR code generator, you could use:

```bash
seedtool --ur | python -c "import sys; print(sys.stdin.readlines()[0].upper())" | qr > seedqrcode.png
```

For this you'll need `Python` and the following package:

```bash
pip install qrcode[pil]
```

2 changes: 1 addition & 1 deletion deps/argp-standalone
2 changes: 1 addition & 1 deletion deps/bc-bip39
Submodule bc-bip39 updated 1 files
+2 −2 src/Makefile.in
2 changes: 1 addition & 1 deletion deps/bc-shamir
Submodule bc-shamir updated 1 files
+2 −2 src/Makefile.in
2 changes: 1 addition & 1 deletion deps/bc-slip39
Submodule bc-slip39 updated 1 files
+2 −2 src/Makefile.in
2 changes: 1 addition & 1 deletion deps/bc-ur
6 changes: 4 additions & 2 deletions src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ OBJS = \
randombytes.o \
hkdf.o

LDFLAGS += -lstdc++
LDLIBS += -lbc-slip39 -lbc-shamir -lbc-crypto-base -lbc-bip39 -lbc-ur -largp

UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
LDLIBS += -lm -lc++ -lc++abi -lgcc_s -lgcc
else ifeq ($(findstring MINGW64, $(UNAME)), MINGW64)
# on windows building with msys2/mingw64
LDLIBS += -lm -lc++ -lws2_32
endif

$(toolname): $(OBJS)
Expand All @@ -91,7 +93,7 @@ format-bytewords.o: format-bytewords.hpp format.hpp params.hpp random.hpp
format-bytewords-uri.o: format-bytewords-uri.hpp format.hpp params.hpp random.hpp
format-bytewords-minimal.o: format-bytewords-minimal.hpp format.hpp params.hpp random.hpp

bindir = $(DESTDIR)/$(prefix)/bin
bindir = $(DESTDIR)$(prefix)/bin

.PHONY: install
install: $(toolname)
Expand Down

0 comments on commit 4bacb67

Please sign in to comment.