5 ms·
> you expect your users to install your app dependencies for you Yes, you do. And that is a good thing. > and you have to figure out the path of your own dep
by enriquto 4y ago
> you expect your users to install your app dependencies for you
Yes, you do. And that is a good thing.
> and you have to figure out the path of your own dependencies.
No, you don't. Once a build dependency is installed, the compiler and the linker find it automatically.
All of this is easier than it sounds. For example, say your program depends on libpng. Then your users will have to "apt get install libpng" (or whatever your distro does). Then on your C files you just write #include <png.h>, on the call to the linker you will have -lpng and everything will work correctly.
The C ecosystem does not favor dependencies whose api changes every month, so this will work with whatever version of the libraries you have. Of course, you are also free to bundle all the dependencies that you want with your code. And you can easily distribute static executables that will work everywhere.
- 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.
- deleted 4y ago[deleted]