The answer was provided by a kind member of SO C++ chat.
It looks like this behaviour is caused by a bug in gcc.
The workaround provided in the last comment of that bug discussion does work and solves the issue:
-Wl,--no-as-needed
More Related Contents:
- VS Code will not build c++ programs with multiple .ccp source files
- Linking g++ 4.8 to libstdc++
- Install gcc on linux with no root privilege
- What is the difference between g++ and gcc?
- How does #include work in C++? [duplicate]
- What are the GCC default include directories?
- Compiling a C++ program with GCC
- C++ standard library and Boehm garbage collector
- How to create a static library with g++?
- What is the purpose of using -pedantic in the GCC/G++ compiler?
- DSO missing from command line [duplicate]
- Compilation fails with “relocation R_X86_64_32 against `.rodata.str1.8′ can not be used when making a shared object”
- 😃 (and other Unicode characters) in identifiers not allowed by g++
- Linking libstdc++ statically: any gotchas?
- openCV program compile error “libopencv_core.so.2.4: cannot open shared object file: No such file or directory” in ubuntu 12.04
- C++ new operator thread safety in linux and gcc 4
- constexpr initializing static member using static function
- How to tell where a header file is included from?
- How to include omp.h in OS X?
- Proper way to create unique_ptr that holds an allocated array
- Linking to MSVC DLL from MinGW
- request for member `…’ is ambiguous in g++
- C and C++ programming on Ubuntu 11.10 [closed]
- GCC: Difference between -O3 and -Os
- Why “initializer-string for array of chars is too long” compiles fine in C & not in C++?
- version `CXXABI_1.3.8′ not found (required by …) [duplicate]
- “to_string” isn’t a member of “std”?
- Find available network interfaces in C/C++? [closed]
- Can I make GCC warn on passing too-wide types to functions?
- How to assert if a std::mutex is locked?