How to store C library dependencies in version control?

Based on the Rails background, I'm used to the fact that I can specify the dependencies of my application in the Gemfile that was noted in my git repository. When my application is pulled, the user just needs to start bundle install, and they have all the necessary dependencies.

In this answer, the community seems to agree that C libraries should not be checked in the source control. It makes sense (after all, gems themselves are not checked under Rails), but this still poses a problem. If I write code and include a new dependency on a user-created library, how can I express this dependency in the original control?

+3
source share
2 answers

Obviously, things in the C world are a little different because you don't need a source at runtime. The general way of working with GNU / Linux (and many other * ix) is that some configuration step is performed using a script or program configuration. The most common of these is the famous configurescript generated by GNU autoconf. Autotools generates many cache files and copies many helper scripts to the source tree, so be sure to install it .gitignoreor you will lose your mind.

pkg-config $prefix/lib/pkgconfig $prefix/share/pkgconfig. pkg-config . , /usr/lib/pkgconfig, , .

autoconf configure.ac configure, m4 ( autoconf). , pkg-config, . configure.ac

:
# Checks for libraries.
PKG_CHECK_MODULES([GLib], [glib-2.0])

, pkg-config , , glib-2.0, Checking for GLib... . GLib_CFLAGS GLib_LIBS , AC_CONFIG_FILES (, Makefile, from Makefile.in). glib, configure . /usr/share/aclocal/pkg.m4, PKG_CHECK_MODULES, . pkg-config(1).

pkg-config, autoconf. , SDL AM_PATH_SDL, pkg-config.

, autoconf. autoconf Debian GNU/Linux MacPorts (, , ), , .m4 .

, , - AC_CHECK_HEADER , - AC_CHECK_LIB.

+3

, , , C .

. , Sqlite, sqlite . , sqlite . , .

. , ?

Linux autotools. , , configure . - , CMake - . , (/usr/lib /usr/include), .

+2

Source: https://habr.com/ru/post/1779547/


All Articles