7

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?

1
  • man gcc, search for libraries (you can do this in google or on your system) Commented Aug 24, 2016 at 16:26

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

If you actually look inside these scripts, the "take care" part is generally done by providing the correct ld scripts to link it with their respective libraries. Would be good, if OP actually gets to read that.
Can I do it without the wrapper?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.