Windows under GCC + Golang compilation Git2go

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Recent research using the go language to manipulate git, in addition to go directly to the command line with the os/exec package, you can also use libgit2 the go binding git2go operation.
But libgit2 is the C language library, go uses cgo the connection C program, needs cgo the support. In short, the process is complicated, fell all the way.

Installing GCC and Pkg-config

The first is the installation gcc and pkg-config (CGO dependent). The GCC compiler recommends using the TDM-GCC to install directly, easy and quick, note do not use the green version of the installation version. pkg-configcan be found in GNOME's official library. pkg-configinstallation needs to be downloaded at the same time:

Http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.26-1_win32.ziphttp://ftp.gnome.org/pub /gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.ziphttp://ftp.gnome.org/pub/gnome/binaries /win32/glib/2.28/glib_2.28.8-1_win32.zip

Copy all EXE and DLLs from the bin directory in several zip packages to the GCC bin directory.

gcc compiler libgit2

Libgit2 is a pure C implementation of the GIT core development package that can be easily ported and embedded into other applications. The website also offers its bindings to various languages, such as the git2go of the Go language.

Golang compiling git2go on a Mac is easy:

Brew Install Libgit2go get Github.com/libgit2/git2go

However, because Git2go and the corresponding libgit2 progress, Windows compile the problem constantly.

Direct git clone the latest libgit2 code (wrong), compiled with CMake. Specific methods in the official Wiki Building libgit2 on Windows has been written clearly, follow the line. The only thing to note is that BUILD_CLAR you can close the compilation parameters without relying on python. Also, use the final parameters of the document:

CMake. -dcmake_install_prefix=c:\libgit2

Compile to a directory where the directory name does not have spaces, otherwise Git2go's wrapper.c will parse the address error. It is recommended to cmake-gui view and set compilation parameters. Compile by wiki:

CMake--build. --target Install

After compiling, add c:/libgit2/lib/pkgconfig to the system variable PKG_CONFIG_PATH so that the pkg-config libgit2.pc file can be found.

Then you can go get it.

But

Later on in the GitHub project, pull#53 found that the latest Libgit2 updated the API to destroy the Git2go. Finally to the classmate of the Mac, found that brew provided by the compilation is 0.20 version, to download release 0.20.0.

Golang compiling Git2go

Git2go compilation The only thing to note is to add c:/libgit2/lib/pkgconfig to the system variable PKG_CONFIG_PATH so that CGO can access the. pc file and read the information about the library. The rest is go get or go install.

Station Address: http://fuxiaohei.me/article/14/windows-git2go.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.