git-crypt icon indicating copy to clipboard operation
git-crypt copied to clipboard

Add Windows compilation instructions

Open Mikulas opened this issue 9 years ago • 9 comments

Hi, I've successfully built both the most recent version and the latest stable tag with those minor updates to the Makefile.

If you are willing to merge this, should I also update the make install task?

Mikulas avatar May 01 '16 20:05 Mikulas

Thanks for working on this! I would definitely like to see better Windows support in git-crypt. However, I think we'd be better off targeting MinGW-w64/MSYS2, considering that it is more actively developed than MinGW/MSYS, and Git itself has switched to it. Also, MSYS2 has the Pacman package manager, so people could install OpenSSL from it instead of having to download a sketchy binary from a third party website.

Would you be able to update the instructions and Makefile for MinGW-w64?

AGWA avatar May 01 '16 21:05 AGWA

Thank you! Turns out msys2 is the best thing ever, who knew :)

I've updated the instructions. No changes to the Makefile are needed now and even the make install step works, assuming git is installed through the msys2 layer.

Mikulas avatar May 04 '16 07:05 Mikulas

The resulting binary was not executable on systems without the compilation requirements. Assuming most users will compile and redistribute, I've modified the makefile to link statically. This obviously produces slightly larger binary (from 350KB to 5MB), but is executable as-is on vanilla Windows.

Mikulas avatar May 04 '16 08:05 Mikulas

Hi, any thoughts on this rewrite? :)

Mikulas avatar May 30 '16 09:05 Mikulas

This works on the current MSYS2.

I did have to link against zlib as well:

Install zlib-devel

pacman -S zlib-devel

Add -lz to LDFLAGS:

diff --git a/Makefile b/Makefile
index 1cb8e8c..be5a445 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ OBJFILES += crypto-openssl.o

 ifeq ($(OS),Windows_NT)
        CXXFLAGS += -static -static-libgcc
-       LDFLAGS += -lcrypto -lgdi32
+       LDFLAGS += -lcrypto -lgdi32 -ldl -lz
 else
        LDFLAGS += -lcrypto
 endif

tomkooij avatar Apr 03 '17 10:04 tomkooij

This pull request with documentation has been very useful for building the windows binary. We have successfully followed the instructions to compile a Windows release.

A note on the comment by @tomkooij : Do not use the -ldl flag as the binary will have dynamic libraries, meaning it cannot be executed outside of MSYS. By removing this flag we were able to run the .exe within Terminal/PowerShell/Cygwin/MSYS etc.

rmeharg avatar Oct 05 '17 10:10 rmeharg

I was just looking into this and I would suggest using the Windows Subsystem for Linux, aka WSL aka bash for Windows. I've managed to successfully build and use git-crypt. Thank you!

tehmaestro avatar Oct 13 '17 17:10 tehmaestro

This is failing for me.

$ make && make install
g++ -Wall -pedantic -Wno-long-long -O2 -static -static-libgcc   -c -o git-crypt.o git-crypt.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -static-libgcc   -c -o commands.o commands.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -static-libgcc   -c -o crypto.o crypto.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -static-libgcc   -c -o gpg.o gpg.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -static-libgcc   -c -o key.o key.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -static-libgcc   -c -o util.o util.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -static-libgcc   -c -o parse_options.o parse_options.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -static-libgcc   -c -o coprocess.o coprocess.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -static-libgcc   -c -o fhstream.o fhstream.cpp
make: *** No rule to make target 'crypto-openssl.o', needed by 'git-crypt'.  Stop.

Any ideas?

chanukov avatar Nov 02 '17 22:11 chanukov

I had to add -lws2_32. See https://github.com/joost-de-vries/git-crypt https://github.com/joost-de-vries/git-crypt/releases/tag/windows%2F0.6.0.1

joost-de-vries avatar Jun 08 '19 10:06 joost-de-vries