question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Subproject links against dynamic library when building both despite -Ddefault_library=static

See original GitHub issue

Minimal example: https://github.com/Myaamori/meson_mwe/tree/master/default_options_override

This is a simple project that calls a subproject in which default_options: ['default_library=both'] is specified.

Build with:

meson -Ddefault_library=static build
ninja -v -C build default_options_override

Meson will link against the shared version of the library when it should opt for the static.

Python version: 3.8.2 Meson version: 0.56.0

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
eli-schwartzcommented, Mar 3, 2021

Right, the general issue here has nothing to do with preferring static or shared and everything to do with subprojects currently being very suboptimal for people wishing to bundle fallback dependencies – this, and several other issues, are due to subprojects being optimized for meta-projects that build and install a collection of projects at once.

This does need fixing, subproject fallback dependencies should default to static and also default to not installing the static library or headers etc.

0reactions
CoffeeFluxcommented, Mar 3, 2021

Nothing, and setting the subproject to static will fix the issue with freetype specifically—I don’t particularly care about the shared library when linking statically. The problem is more that I don’t think I should have to go set the default_library manually for every single subproject that is building both by default. A lot of the time I want to link against the shared version, but for release builds on Windows I essentially want to say “link statically or die”. Barring that, “link statically when both options are available” would be an improvement over the status quo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CMake: how create a single shared library from all static ...
I would like to link these static libraries in a single shared library at the top_project level. The information I gathered so far...
Read more >
Subprojects - The Meson Build system
A subproject example. Usually dependencies consist of some header files plus a library to link against. To declare this internal dependency use ...
Read more >
Building And Using Static And Shared "C" Libraries
Shared libraries (also called dynamic libraries) are linked into the program in two stages. First, during compile time, the linker verifies that all...
Read more >
Dynamic linking best practices - begriffs.com
In this article we'll learn how to build shared libraries and install them properly on several platforms. For guidance, we'll examine the ...
Read more >
How to make a subproject export a link directory of a library ...
(static linking with dynamic loading) FreeImage (built as a shared library). I can correctly build perceptualdiff on its own.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found