SFML, in this case, has a Git repo and a download page. Until now I have always downloaded from the download page, which came (at least for the compiler I use) with .a and .hpp files and could easily be used with MinGW with -l and -i tags.

When I wanted to use this on Github, though, a couple of problems arised.

  1. When copying it into the repo on the first commit, the Github graph would show 22k changes on the first commit and only a couple hundred on the following commits. I got around this by putting the download into a private repo and using it as a submodule. This isn't very elegant and still has the problem of being OS/compiler-specific.

  2. Using the official Github repo as a submodule. But how do you use external raw cpp and hpp files? Do you put the necessary cpp files into the Makefile? If so, what are the downloads on the download page for?

  • My friend told me today that you don't put external libraries in git, but you let others download them for themselves
    – Post Self
    Jan 23, 2017 at 11:27
  • Should that library be added to .gitignore or to .git/info/exclude, though?
    – Post Self
    Jan 23, 2017 at 16:13
  • You can add the libraries as a git submodule, but most libraries aren't really set up properly to use that. It works quite well for the ones that do though. Jan 24, 2017 at 1:32

2 Answers 2


Adding a library in your git repo would make you a maintainer of another version of the library. You want to avoid that as much as possible.

Depending on the library and the target OS, the most reasonable approach is to have it listed as a dependency in the README, along with good documentation on how to install it on all target operating systems, or links to resources that describe how to install it. Maybe, if possible, provide an automated script, but it's not really necessary and not really helpful since building from source should be reserved to developers and power users.

For "normal" users, you should provide binaries that integrate with the operating system's dependency manager (preferably) or just contain a copy of the library.

  • 2
    This is also very dependant on the programming language - in any widely used programming language there's likely one or more typical dependency management tools that people use. Instead of committing a copy of a third party library to your repo you commit config for that tool. E.g Maven & Gradle in Java, NPM in Javascript, Composer in PHP, PIP in Python, Cargo in Rust etc etc.
    – bdsl
    Mar 22, 2023 at 14:57

If you need full control over the external lib, one option would be:

  • Fork your own repo from the original one.
  • Add your own custom build scripts for each OS you need (this usually means wraping your own scripts around existing build scripts - usually not much work).
  • Build the binaries you need, per OS, keep them, Git tag them, and use with your original project.
  • When the binaries get too old, sync your forked repo with original one, update build scripts, and build again. Tag a new version, use it, repeat...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.