Biblioteki:

  • gLib (G Library) - niskopoziomowa, narzędziowa biblioteka funkcji dla programistów języka C, dostarczająca jednolite API. Wykorzystywana przez GTK+
  • libc = Biblioteka standardowa języka C
    • glibc = GNU libc (glibc lub libc6) – wersja standardowej biblioteki języka C, stworzona w ramach projektu GNU.
  • gnulib [1]

libc edytuj

wersje edytuj

  • glibc (Fedora/Redhat family, Arch) [2]
  • eglibc (Debian/Ubuntu family);

c edytuj

// http://man7.org/linux/man-pages/man3/gnu_get_libc_version.3.html
// http://stackoverflow.com/questions/9705660/check-glibc-version-for-a-particular-gcc-compiler/20155150#20155150

#include <gnu/libc-version.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[])
       {
           printf("GNU libc version: %s\n", gnu_get_libc_version());
           printf("GNU libc release: %s\n", gnu_get_libc_release());
           exit(EXIT_SUCCESS);
       }

Program zapisujemy jako t.c, kompilujemy:

gcc t.c

i uruchamiamy:

./a.out

przykładowy wynik:

GNU libc version: 2.17
GNU libc release: stable

ldd edytuj

Po skompilowaniu programu (standardowa nazwa a.out) sprawdzamy jakie mamy biblioteki za pomocą ldd:[3]

 ldd ./a.out

przykładowy wynik:

linux-vdso.so.1 =>  (0x00007fff15dfe000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ffd3e2b0000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffd3dee8000)
/lib64/ld-linux-x86-64.so.2 (0x00007ffd3e5d4000)

albo prościej: [4]

ldd --version

przykładowy wynik:

ldd (Ubuntu EGLIBC 2.17-93ubuntu4) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
To oprogramowanie jest darmowe; warunki kopiowania są opisane w źródłach.
Autorzy nie dają ŻADNYCH gwarancji, w tym również gwarancji MOŻLIWOŚCI
SPRZEDAŻY lub PRZYDATNOŚCI DO KONKRETNYCH ZASTOSOWAŃ.
Autorami są Roland McGrath i Ulrich Drepper.

gcc edytuj

W konsoli wpisujemy:

gcc -print-file-name=libc.so

przykładowy wynik:

/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libc.so

ldd i gcc edytuj

ldd -v <path/to/gcc-4.x>

znajdujemy gcc:

which gcc

przykładowy wynik:

/usr/bin/gcc

Zapytanie o wersję:

 ldd -v /usr/bin/gcc

przykładowy wynik:

	linux-vdso.so.1 =>  (0x00007fff69542000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f825f6d4000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f825fabc000)

	Version information:
	/usr/bin/gcc:
		ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
		libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
		libc.so.6 (GLIBC_2.8) => /lib/x86_64-linux-gnu/libc.so.6
		libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
		libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
		libc.so.6 (GLIBC_2.11) => /lib/x86_64-linux-gnu/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
		libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
	/lib/x86_64-linux-gnu/libc.so.6:
		ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
		ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2

libc.so edytuj

Znajdujemy libc.so:


locate libc.so
/lib/i386-linux-gnu/libc.so.6
/lib/x86_64-linux-gnu/libc.so.6
/usr/lib/x86_64-linux-gnu/libc.so

Uruchamiamy:

/lib/x86_64-linux-gnu/libc.so.6

Przykładowy wynik:

GNU C Library (Ubuntu EGLIBC 2.17-93ubuntu4) stable release version 2.17, by Roland McGrath et al.
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.7.3.
Compiled on a Linux 3.11.3 system on 2013-10-12.
Available extensions:
	crypt add-on version 2.1 by Michael Glad and others
	GNU Libidn by Simon Josefsson
	Native POSIX Threads Library by Ulrich Drepper et al
	BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<https://bugs.launchpad.net/ubuntu/+source/eglibc/+bugs>.

math.h edytuj

 locate math.h
/home/a/Pobrane/xfractint-20.04p12/headers/fmath.h
/home/a/Pobrane/xfractint-20.04p12/headers/mpmath.h
/home/a/pyopencl/bpl-subset/bpl_subset/boost/config/no_tr1/cmath.hpp
/usr/include/math.h
/usr/include/tgmath.h
/usr/include/boost/config/no_tr1/cmath.hpp
/usr/include/boost/geometry/util/math.hpp
/usr/include/boost/multiprecision/tommath.hpp
/usr/include/boost/phoenix/stl/cmath.hpp
/usr/include/boost/tr1/cmath.hpp
/usr/include/boost/units/cmath.hpp
/usr/include/c++/4.6/tgmath.h
/usr/include/c++/4.6/tr1/math.h
/usr/include/c++/4.6/tr1/tgmath.h
/usr/include/c++/4.8/tgmath.h
/usr/include/c++/4.8/tr1/math.h
/usr/include/c++/4.8/tr1/tgmath.h
/usr/include/python2.7/pymath.h
/usr/include/qt4/Qt/qmath.h
/usr/include/qt4/QtCore/qmath.h
/usr/include/qt5/QtCore/qmath.h
/usr/lib/gcc/x86_64-linux-gnu/4.6/include/quadmath.h
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/quadmath.h
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_math.h
/usr/lib/syslinux/com32/include/math.h
/usr/share/R/include/Rmath.h
/usr/share/doc/texlive-doc/generic/tex-virtual-academy-pl/latex2e/macro/extmath.html
/usr/share/doc/texlive-doc/latex/bosisio/envmath.html
/usr/share/doc/texlive-doc/latex/isomath/isomath.html
/usr/share/libreoffice/help/en-US/smath.ht
/usr/share/libreoffice/help/pl/smath.ht
/usr/share/pyshared/numpy/core/include/numpy/npy_math.h
/usr/share/texlive/texmf-dist/tex/latex/hyper/amsmath.hyp

NAN edytuj

a@zalman:~$ grep -n "NAN"  /usr/include/math.h 
41:/* Get machine-dependent NAN value (returned for some domain errors).  */
185:    FP_ILOGBNAN	Expands to a value returned by `ilogb (NAN)'.
195:    FP_NAN =
196:# define FP_NAN 0
197:      FP_NAN,
473:      fpclassify (__u) == FP_NAN || fpclassify (__v) == FP_NAN; }))
a@zalman:~$ grep -n "nan"  /usr/include/math.h 
42:# include <bits/nan.h>
252:   we already have this functions `__isnan' and it is faster.  */
254:#  define isnan(x) \
255:     (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
257:#  define isnan(x) \
259:      ? __isnanf (x)							      \
261:      ? __isnan (x) : __isnanl (x))
a@zalman:~$ locate nan.h
/usr/include/x86_64-linux-gnu/bits/nan.h
a@zalman:~$ grep -n "nan" /usr/include/x86_64-linux-gnu/bits/nan.h
20:# error "Never use <bits/nan.h> directly; include <math.h> instead."
28:# define NAN	(__builtin_nanf (""))
42:#  define __nan_bytes		{ 0x7f, 0xc0, 0, 0 }
45:#  define __nan_bytes		{ 0, 0, 0xc0, 0x7f }
48:static union { unsigned char __c[4]; float __d; } __nan_union
49:    __attribute_used__ = { __nan_bytes };
50:# define NAN	(__nan_union.__d)
a@zalman:~$ 

Źródła edytuj

  1. Gnulib w ang wikipedii
  2. unix.stackexchange questions: what-c-library-version-does-my-system-use
  3. Installing as a test library from The glibc 2 HOWTO covers installing and using the GNU C Library version 2 (libc 6) on Linux systems. by Eric Green, ejg3@cornell.edu v1.6, 22 June 1998
  4. Check glibc version for a particular gcc compiler