#include <stdio.h> // for printf()
#include <gnu/libc-version.h> // for gnu_get_libc_release(), gnu_get_libc_version()
// /usr/include/x86_64-linux-gnu/gnu/libc-version.h
int main()
{
printf("libc-release: %s\n", gnu_get_libc_release());
printf("libc-version: %s\n", gnu_get_libc_version());
return 0;
}
/*
gcc version.c -o version
./version
libc-release: stable
libc-version: 2.31
ldd ./version | grep libc
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
/lib/x86_64-linux-gnu/libc.so.6
GNU C Library (Ubuntu GLIBC 2.31-0ubuntu9.9) stable release version 2.31.
...
Compiled by GNU CC version 9.4.0.
...
Folder /lib/x86_64-linux-gnu also contains libc.a, libc.so, libc-2.31.so:
/usr/lib/x86_64-linux-gnu/libc.a
/usr/lib/x86_64-linux-gnu/libc.so
/usr/lib/x86_64-linux-gnu/libc-2.31.so
libc.so.6 is a link to libc-2.31.so
*/
*********************************************************************************
*********************************************************************************
*********************************************************************************
*********************************************************************************
*********************************************************************************
#include <stdio.h> // for printf(), NULL
#include <stddef.h> // for size_t
#include <unistd.h> // for confstr()
// unistd.h includes bits/confname.h, which defines
// _CS_PATH, _CS_GNU_LIBC_VERSION
int main()
{
char buf[100];
size_t n;
n = confstr(_CS_PATH, NULL, (size_t) 0);
confstr(_CS_PATH, buf, n);
printf("_CS_PATH: %s\n", buf);
n = confstr(_CS_GNU_LIBC_VERSION, NULL, (size_t) 0);
confstr(_CS_GNU_LIBC_VERSION, buf, n);
printf("_CS_GNU_LIBC_VERSION: %s\n", buf);
return 0;
}
/*
gcc confstr.c -o confstr
./confstr
_CS_PATH: /bin:/usr/bin
_CS_GNU_LIBC_VERSION: glibc 2.31
*/
*********************************************************************************
*********************************************************************************
*********************************************************************************
*********************************************************************************
*********************************************************************************