Questions tagged [libc]

The C standard library consists of a set of sections of the ISO C standard which describe a collection of headers and library routines used to implement common operations, such as input/output and string handling, in the C programming language.

The C standard library consists of a set of sections of the ISO C standard which describe a collection of headers and library routines used to implement common operations, such as input/output and string handling, in the C programming language.

There are many implementations of libc with different resource requirements, security goals, etc. With a typical tool chain the libc, compiler and OS work together to achieve some ISO, Posix or custom features/standards. Some libc implementation are only a subset of the ISO standard, but still full featured enough to be used in many applications.

Specific libc tags:

  • - the full Gnu Libc found on most GCC installs.
  • - a smaller micro-controller libc for resource constrained devices
  • - Android libc
  • - unhosted libc
  • - more modern lighter foot print libc

Websites

See also:

Do not confuse with , which is for the C++ programming language.

1076 questions
12
votes
3 answers

Build and bind against older libc version

I have dependencies in my code that requires libc. When building (cargo build --release) on Ubuntu 20.04 (glibc 2.31) the resulting executable doesn't run on CentOS 7 (glibc 2.17). It throws an error saying it requires GLIBC 2.18. When build the…
Michael
  • 2,528
  • 3
  • 21
  • 54
12
votes
1 answer

Why do program-level constructors get called by `__libc_csu_init` but destructors don't get called by `__libc_csu_fini`?

Here's a simple program: void __attribute__ ((constructor)) dumb_constructor(){} void __attribute__ ((destructor)) dumb_destructor(){} int main() {} I compile it with the following flags: g++ -O0 -fverbose-asm -no-pie -g -o main main.cpp I…
OneRaynyDay
  • 3,658
  • 2
  • 23
  • 56
12
votes
1 answer

Why does an fread loop require an extra Ctrl+D to signal EOF with glibc?

Normally, to indicate EOF to a program attached to standard input on a Linux terminal, I need to press Ctrl+D once if I just pressed Enter, or twice otherwise. I noticed that the patch command is different, though. With it, I need to press Ctrl+D…
12
votes
9 answers

How to sleep for a few microseconds

Consider the following code: #include #include #include // Compile with gcc -lrt -lm -o test_clock test_clock.c #define CLOCK CLOCK_MONOTONIC int main(int argc, char** argv) { double temp, elapsed; int j; …
Nikratio
  • 2,338
  • 2
  • 29
  • 43
12
votes
3 answers

Why are fopen arguments restrict qualified in the C Standard and header file?

The standard library function fopen is declared in as: FILE *fopen(const char * restrict filename, const char * restrict mode); This is also how the function prototype appears in the C Standard. Why are the arguments restrict qualified?
chqrlie
  • 131,814
  • 10
  • 121
  • 189
12
votes
2 answers

Difference between FILE * "/dev/stdout" and stdout

Let's have a look at this Hello World program #include int main(int argc, char ** argv) { printf("Hello, World!"); const char* sFile = "/dev/stdout"; // or /proc/self/fd/0 const char* sMode = "w"; FILE * output =…
MrPaulch
  • 1,423
  • 17
  • 21
12
votes
1 answer

I just destroyed libc.so on my machine. What can I do now?

I was SSHed into a remote box as root when I ran the following command: ln -sf /nonexistent /.../libc.so Immediately my prompt started throwing errors: basename: could not find shared library I can't even run anything: root@toastbox# ls ls: could…
nneonneo
  • 171,345
  • 36
  • 312
  • 383
12
votes
2 answers

Why is isascii() deprecated?

According to the isascii() manpage: http://linux.die.net/man/3/isascii POSIX.1-2008 marks isascii() as obsolete, noting that it cannot be used portably in a localized application. I'm not sure I see where the portability problem is. A very…
Matthew Fioravante
  • 1,478
  • 15
  • 19
12
votes
1 answer

Runtime Library mis-matches and VC++ - Oh, the misery!

It seems that all my adult life I've been tormented by the VC++ linker complaining or balking because various libraries do not agree on which version of the Runtime library to use. I'm never in the mood to master that dismal subject. So I just try…
Jive Dadson
  • 16,680
  • 9
  • 52
  • 65
12
votes
1 answer

Undefined reference to `clock_gettime` although `-lrt` is given

I've give -lrt as the last linker flag to the compiler. But still getting this error. arif@khost:~/sak/sak.exosip$ gcc eXo_init.c -I/opt/osip2/include -I/opt/exosip/include -L/opt/osip2/lib -L/opt/exosip/lib -leXosip2 -losipparser2 -losip2…
Aftnix
  • 4,461
  • 6
  • 26
  • 43
12
votes
2 answers

Build static ELF without libc using unistd.h from Linux headers

I'm interested in building a static ELF program without (g)libc, using unistd.h provided by the Linux headers. I've read through these articles/question which give a rough idea of what I'm trying to do, but not…
sega01
  • 223
  • 2
  • 5
12
votes
3 answers

Fatal signal 7 (SIGBUS) at 0x00000000 (code=2)

While using a OSGi Platform on Android i got this errormsg: Fatal signal 7 (SIGBUS) at 0x595302e0 (code=2) I don't think that my app needs that much space in memory or need a lot of computation power. Its just the OSGi Platform with 20 Bundles. My…
Rob Anderson
  • 2,377
  • 3
  • 22
  • 31
12
votes
2 answers

How to build a static binary for GNU/Linux installations with old kernel?

$ printf 'int main(){}' | gcc -static -x c - -o hello $ scp hello vi-server.org:./ hello 100% 565KB 565.2KB/s 00:00 $ ssh -t vi-server.org "./hello; uname -r" FATAL: kernel too old sh: line 1: 15378 Segmentation…
Vi.
  • 37,014
  • 18
  • 93
  • 148
11
votes
3 answers

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)

I am creating a 2D game on Android using OpenGL. Currently I am testing and debugging the game on several devices. The problem I am facing, is the terrible "signal 11" error. When I am playing on my Samsung Galaxy Nexus, everything runs smooth, and…
Edwin Morren
  • 149
  • 1
  • 1
  • 4
11
votes
2 answers

Understanding glibc source code conventions

I've been looking at some of the source code for glibc, in particular the nptl code, and I've found it a little bit hard to understand since it seems to have conventions that I'm not familiar with. For example I was looking at a very small file…
Gabriel Southern
  • 9,602
  • 12
  • 56
  • 95