Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build on Windows using MSYS2 #307

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open

Conversation

clns
Copy link
Contributor

@clns clns commented Apr 30, 2016

Similar to Unix, this allows running make install from a MinGW shell
on Windows, installed using MSYS2.

Prerequisites:

Build libgit2 and git2go:

  • Open the "MinGW-w64 Win64 Shell" (or 32-bit) and run make install
    from the root of git2go. 'git2go.a' should install in
    'GOPATH\pkg\windows_amd64\github.com\libgit2'.

When building your app, you'll need gcc available in your PATH,
so you might want to add 'C:\msys64\mingw64\bin' to the PATH.

Similar to Unix, this allows running 'make install' from a MinGW shell
on Windows, installed using MSYS2.

Prerequisites:

- Install MSYS2 from http://msys2.github.io and follow the instructions
  on that page
- Install MinGW as explained here http://stackoverflow.com/a/30071634/1104534
- In addition to 'mingw-w64-x86_64-gcc', you'll also need the following:
  $ pacman -S make mingw-w64-x86_64-cmake mingw-w64-x86_64-pkg-config

Build libgit2 and git2go:

- Open the "MinGW-w64 Win64 Shell" (or 32-bit) and run 'make install'
from the root of git2go. 'git2go.a' should install in
'GOPATH\pkg\windows_amd64\github.com\libgit2'.

When building your app, you'll need gcc available in your PATH,
so you might want to add 'C:\msys64\mingw64\bin' to the PATH.
@clns clns mentioned this pull request Apr 30, 2016
@ktsakas
Copy link

ktsakas commented Jul 20, 2016

I get the following error:

\# github.com/libgit2/git2go
gcc: error: Files: No such file or directory
gcc: error: (x86)/libgit2/include: No such file or directory

I think the reason is that go build does no escape spaces on Windows paths properly.
I suspect the problem is in the build.go file.

@dbalabka
Copy link

dbalabka commented Aug 19, 2016

You safe my day! I had to install MSYS2 from scratch to compile it. Otherwise catch different strange errors

@carlosmn
Copy link
Member

The only difference between these seems to be the generator. I'd rather see that part be part of common code and then add the different args in whichever conditional is appropriate.

@clns
Copy link
Contributor Author

clns commented Oct 26, 2016

Indeed the only change is the generator, however it took me a while to figure out all the bits and pieces to be able to compile it on Windows. Also this PR includes the details on how to prepare the MSYS2 environment.

I would suggest we either use this change, or at least add the instructions somewhere in the README so it's easier for anyone to find it, and maybe change the file to accept a generator given as arg in cli.

@mschenk42
Copy link

Hoping this might help others. Took me a good amount of time to get this to work with the master branch. I'm pretty happy with the process. It is little kludgy for a Go build. I wasn't able to vendor git2go like other go packages.

Take a look at the appveyour.yml and the script directory for the Windows build process in this project https://github.com/git-time-metric/gtm.

@Fjolnir-Dvorak
Copy link

hmm, I get another error when trying to run $ make install on a fresh install of msys:
(Sorry, still need to try to get mingw to output english on a german computer)

[100%] Linking C static library libgit2.a
make[3]: Verzeichnis „/c/cygwin64/home/THORRAFNRIKR/workspace/go/src/github.com/libgit2/git2go/vendor/libgit2/build“ wird verlassen
[100%] Built target git2
make[2]: Verzeichnis „/c/cygwin64/home/THORRAFNRIKR/workspace/go/src/github.com/libgit2/git2go/vendor/libgit2/build“ wird verlassen
make[1]: Verzeichnis „/c/cygwin64/home/THORRAFNRIKR/workspace/go/src/github.com/libgit2/git2go/vendor/libgit2/build“ wird verlassen
go install ./...
# github.com/libgit2/git2go
.\blame.go:4:18: fatal error: git2.h: No such file or directory
compilation terminated.
make: *** [Makefile:8: install] Fehler 2

In short: It is successfully compiling a static libgit2.a binary and is not able to build the wrapper afterwards. The error code is 2.

@mschenk42
Copy link

The windows build is working again for this project https://github.com/git-time-metric/gtm. Review the appveyor.yml, .travis.yml and scripts directory for how to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants