3 ms·
> No, you don't. Once a build dependency is installed, the compiler and the linker find it automatically. Except when they don't. And you're left to figure ou
by VWWHFSfQ 4y ago
> No, you don't. Once a build dependency is installed, the compiler and the linker find it automatically.
Except when they don't.
And you're left to figure out the right incantation of linker flags to use. Maybe give up and start symlinking stuff around until it works.
- db48x 4y agoCompiler and linker flags are so annoying that people built tools to make developers lives easier. They aren’t amazing tools, but they get the job done. In this case, you would run `pkg-config -cflags libfoo` and `pkg-config -libs libfoo` and use the results when you invoke the compiler and linker.
- enriquto 4y ago> Compiler and linker flags are so annoying (...) Hmmm. I'd rather say that some people who package libraries are very annoying! If a library needs specific compiler flags, or linker flags beyond "-lfoo", this means that somebody is doing something wrong. Out of incompetence or out of malice.
- db48x 4y agoWell, I dunno. libpng needs -lpng16 and -lz. Are you saying that libpng should have a staticly–linked copy of zlib inside of it, so that if your application needs both libpng and zlib you will end up with both? That’s probably unpalatable to most people.
- enriquto 4y ago> libpng needs -lpng16 and -lz Where? I'm compiling the same program with exactly the same makefile on several linux distributions, openbsd, freebsd and macos and "-lpng" is all it needs. This is for dynamic linking. For static linking I need to add -lz explicitly, you are right about that.