Questions tagged [glibc]

The GNU C library is used as the C library in the GNU system and most systems with the Linux kernel. It defines the "system calls" and other basic facilities such as open, malloc, printf, exit, etc.

2271 questions
304
votes
9 answers

Why does glibc's strlen need to be so complicated to run quickly?

I was looking through the strlen code here and I was wondering if the optimizations used in the code are really needed? For example, why wouldn't something like the following work equally good or better? unsigned long strlen(char s[]) { unsigned…
user11954200
233
votes
11 answers

Multiple glibc libraries on a single host

My linux (SLES-8) server currently has glibc-2.2.5-235, but I have a program which won't work on this version and requires glibc-2.3.3. Is it possible to have multiple glibcs installed on the same host? This is the error I get when I run my program…
dogbane
  • 266,786
  • 75
  • 396
  • 414
188
votes
7 answers

How can I link to a specific glibc version?

When I compile something on my Ubuntu Lucid 10.04 PC it gets linked against glibc. Lucid uses 2.11 of glibc. When I run this binary on another PC with an older glibc, the command fails saying there's no glibc 2.11... As far as I know glibc uses…
falstaff
  • 3,413
  • 2
  • 25
  • 26
117
votes
4 answers

Using C++ library in C code

I have a C++ library that provides various classes for managing data. I have the source code for the library. I want to extend the C++ API to support C function calls so that the library can be used with C code and C++ code at the same time. I'm…
Misha M
  • 10,979
  • 17
  • 53
  • 65
87
votes
2 answers

difference between gcc -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2

Can someone point out the difference between gcc -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2? I guess =2 is more secure? I haven't been able to find a list which lists differences point by point. I have also read that -D_FORTIFY_SOURCE=2 should be…
Frank Meerkötter
  • 2,778
  • 2
  • 20
  • 26
86
votes
3 answers

Why is statically linking glibc discouraged?

Most of the sources online state that you can statically link glibc, but discourage from doing so; e.g. centos package repo: The glibc-static package contains the C library static libraries for -static linking. You don't need these, unless you…
pzelasko
  • 2,082
  • 1
  • 16
  • 24
83
votes
2 answers

Compiling without libc

I want to compile my C-code without the (g)libc. How can I deactivate it and which functions depend on it? I tried -nostdlib but it doesn't help: The code is compilable and runs, but I can still find the name of the libc in the hexdump of my…
u149796
  • 1,788
  • 4
  • 14
  • 19
77
votes
6 answers

Is there a best practice on setting up glibc on docker alpine linux base image?

Is there a best practice on setting up glibc on docker alpine linux base image with correct paths so any spawned process can correctly reference the location of the installed libc libraries?
kai
  • 817
  • 1
  • 6
  • 8
76
votes
6 answers

Linux static linking is dead?

In fact, -static gcc flag on Linux doesn't work now. Let me cite from the GNU libc FAQ: 2.22. Even statically linked programs need some shared libraries which is not acceptable for me. What can I do? {AJ} NSS (for details just type `info libc…
Shcheklein
  • 5,979
  • 7
  • 44
  • 53
75
votes
9 answers

Check glibc version for a particular gcc compiler

I have two gcc compilers installed on my system, one is gcc 4.1.2 (default) and the other is gcc 4.4.4. How can I check the libc version used by gcc 4.4.4, because /lib/libc.so.6 shows the glibc used by gcc 4.1.2, since it is the default compiler.
MetallicPriest
  • 29,191
  • 52
  • 200
  • 356
73
votes
2 answers

Why is this code using strlen heavily 6.5x slower with GCC optimizations enabled?

I wanted to benchmark glibc's strlen function for some reason and found out it apparently performs much slower with optimizations enabled in GCC and I have no idea why. Here's my code: #include #include #include…
Display Name
  • 773
  • 6
  • 9
72
votes
4 answers

How to upgrade glibc on Debian?

I heard I can do it using apt-get install libc6, but I need to add something to /etc/apt/sources.list to receive the newest glibc version. What should I do?
antpetr89
  • 1,143
  • 3
  • 12
  • 14
70
votes
8 answers

Will malloc implementations return free-ed memory back to the system?

I have a long-living application with frequent memory allocation-deallocation. Will any malloc implementation return freed memory back to the system? What is, in this respect, the behavior of: ptmalloc 1, 2 (glibc default) or 3 dlmalloc tcmalloc…
osgx
  • 90,338
  • 53
  • 357
  • 513
69
votes
5 answers

What is GLIBC? What is it used for?

I was searching for the source code of the C standard libraries. What I mean with it is, for example, how are cos, abs, printf, scanf, fopen, and all the other standard C functions written, I mean to see their source code. So while searching for…
user1261015
62
votes
6 answers

Does standard c library provides linked list etc. data structures?

Do standard C library implementations, especially glibc (the GNU C Library) provide linked lists, stack et al. data structures, or do we have to roll our own? Thanks.
rsjethani
  • 2,179
  • 6
  • 24
  • 30
1
2 3
99 100