Skip to content

Building, testing, and using libgit2

crakdmirror edited this page Apr 30, 2011 · 8 revisions

Back Home, or previous: Introduction to libgit2 API

Building libgit2

This process is actually really simple. The libgit2 project uses waf, which is an extremely lightweight build/testing tool that's small enough that you can literally embed it in your project. It makes building, installing, and testing your project as a library super simple, as if someone had made make awesome and then shrunk it with that laser machine Rick Moranis has in "Honey I Shrunk the Kids". From the root directory of your libgit2, run:

$ ./waf configure
$ ./waf build-static
$ ./waf build-shared
$ ./waf test
$ ./waf install

After running these commands, you can link directly to the library from just about any C program in just about any place on your filesystem:

/* main.c */
#include <git2.h>

main() {}

Compiling this is as straightforward as it looks:

gcc main.c -lgit2

Re-building libgit2 after you've changed the code

Simple: ./waf install. This command will literally re-build the project make-style and then install so that you can (as above) link it in just regular C programs wherever on your computer.

Back Home, or previous: Introduction to libgit2 API