Reputation: 77
On some platforms like Microsoft Windows no need to link against the "Standard C Library" with -lc
flag, But on some other platforms it requires linking, But on macOS/OSX though it's Unix-based we don't link with -lc
while we need to link on Linux and BSDs...
That made me a bit confused when writing Cross-Platform C libraries, Where and When to/not to link against the "Standard C Library" with -lc
flag?
And is linking just for Linux and BSDs? Or also some other Unix platforms requires linking?
Upvotes: 1
Views: 1323
Reputation: 224546
Essentially every hosted C implementation requires you to link programs with an implementation of the standard C library.
Some commands for building programs have the inclusion of the standard C library built-in as a default, so you do not need to add it explicitly on the command library. Some commands do not have it as a default, so you do need to add it on the command line.
Upvotes: 3