Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile with an another libC on Linux? (gcc)

Tags:

c

gcc

libc

I want to compile my C program with an another C library like dietlibc or musl.

What gcc option should I use for this purpose?

like image 424
meridj Avatar asked Aug 24 '16 13:08

meridj


1 Answers

What gcc option should I use for this purpose?

You should read dietlibc or musl documentation. Example for dietlibc from here:

diet gcc -pipe -g -o t t.c

That is: dietlibc provides a wrapper command called diet which takes care of this for you.

Example for musl from here:

musl-gcc -static -Os hello.c

That is, musl provides a wrapper command called musl-gcc which takes care of this for you.

You can examine musl-gcc and diet to see exactly what options they pass the to the linker. Note however that the exact options may change from version to version, and you are better off always using the wrappers even if you know exactly which flags they pass.

like image 79
Employed Russian Avatar answered Oct 03 '22 10:10

Employed Russian