Add Windows compilation instructions
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?
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?
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.
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.
Hi, any thoughts on this rewrite? :)
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
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.
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!
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?
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