4 ms·
> So why not just statically link at this point? In many cases, you just can't. Other than glibc having issues with static linking, you can't use `dlopen` in
by RaisingSpear 3y ago
> So why not just statically link at this point?
In many cases, you just can't. Other than glibc having issues with static linking, you can't use `dlopen` in a static binary.
For example, if you're building an application which can use OpenCL, you need to dynamically link to the ICD installed on the system. And because `dlopen` doesn't work in a static application, you're stuck with dynamic linking the whole application (or at least with libc).
On the other hand, Windows has no issue with `LoadLibrary` in a static binary...
I don't know enough about GUI applications, but I wouldn't be surprised if anything needing graphical output is in a similar boat.
The cherry on top is that glibc doesn't make it easy for an application to be built for an older version of the library.
As Linus Torvalds can attest to [https://www.youtube.com/watch?v=Pzl1B7nB9Kc https://www.youtube.com/watch?v=Pzl1B7nB9Kc] building for Linux sucks.
- arp242 3y agoYou can statically link at least GTK applications (less sure about Qt, never tried), but many build systems don't support it very well and it requires some amount of hackery. The best trade-off is probably "link against libc, statically link everything else". That gives you dlopen() and some security benefits. But again, build systems don't support it very well out of the box. I think the outright hostility against static linking has been unfortunate, because now we have a whole bunch of "static linking, but with extra steps" systems to work around it. Dynamic linking is fine for many things, but it's obviously not always the best solution. It's disappointing that essentially nothing really improved in the 10 years since Linus gave that talk. Okay, there's flatpak and appimage and snap which are an "improvement" of sorts, but it's all pretty complex and half the time when I wanted to run one it didn't work well.