f2e-spec icon indicating copy to clipboard operation
f2e-spec copied to clipboard

Build performous with staticly linked deps

Open Baklap4 opened this issue 4 years ago • 5 comments
trafficstars

Do you want to request a feature or report a bug?

Feature

What did you expect to see?

It'd be nice to have a staticly linked build. This is especially useful when distributing default packages like deb, rpm, targz, dmg. All of the dependant libraries will be baked in within the executable and distribution land is happy as long as you're running on the same architecture

Todo

  • [ ] Create a cmake option to link staticly or dynamic
  • [ ] Dynamic -> Use the current build route
  • [ ] Static -> Link all the deps staticly

Baklap4 avatar Jul 20 '21 16:07 Baklap4

Static builds are very difficult because the existing CMake scripts probably aren't written well enough to pull in all the dependencies and in the right order. In dynamic builds the inter-library deps are handled automatically but static building requires a lot of hackery with the linking flags.

Good luck with the effort. Meson is probably going to be the easier way here.

Tronic avatar Jul 23 '21 09:07 Tronic

If there are other ways to easily distribute the dependant libraries i'd love to hear them. Currently in #532 things only work on the exact same machine with the same version of the libraries installed, because of the nature of dynamic builds

Baklap4 avatar Jul 23 '21 09:07 Baklap4

If there are other ways to easily distribute the dependant libraries i'd love to hear them. Currently in #532 things only work on the exact same machine with the same version of the libraries installed, because of the nature of dynamic builds

Shouldn't you be able to compile with -Wl,-rpath -Wl,.? and then ship all libraries along with the executable? That's essentially what a macOS bundle does.

Lord-Kamina avatar Jul 24 '21 16:07 Lord-Kamina

If there are other ways to easily distribute the dependant libraries i'd love to hear them. Currently in #532 things only work on the exact same machine with the same version of the libraries installed, because of the nature of dynamic builds

Well ldd gives you all lib deps, and one may use LD_LIBRARY_PATH to point the performous directory pior to the system's one. This is a quite common way to proceed by having a simple script that sets the environment variable and launch the binary. That said, distros have maintainers, I think it would be more efficient to get in touch with them and help them to create packages updates.

OznOg avatar Jul 24 '21 19:07 OznOg

Yeah now that I think about it, my solution doesn't address nested dependencies.

If we want to get hacky, maybe it wouldn't be that hard to make a script around ldd to do this. Does linux have install_name_tool?

Lord-Kamina avatar Jul 24 '21 19:07 Lord-Kamina