While K&R C is a good reference, I'd like to read about the compile-time and run-time linking. Compilation errors are usually easy to debug, but linking errors are mostly cryptic (to me). Why is the symbol missing if I'm providing the library? Where can I find the symbol? What are those dependencies listed by ldd on the simplest hello world? What does libstdc provide? And others?

Any good reading material?

#c #cpp #askfedi #askfediverse

Follow

@vesperto
This article, while more about ELF than about linking, might provide useful insight - and teach you how to create the smallest possible executable (45 Bytes)

muppetlabs.com/~breadbox/softw

On missing symbols: By default, if you ln main foo bar, they are linked in that order. Only the symbols of foo that are referenced in main will be used. If bar only references symbols that main also references, it will still work. But if bar references additional foo symbols, they stay missing.

Sign in to participate in the conversation
Librem Social

Librem Social is an opt-in public network. Messages are shared under Creative Commons BY-SA 4.0 license terms. Policy.

Stay safe. Please abide by our code of conduct.

(Source code)

image/svg+xml Librem Chat image/svg+xml