What does C++ standard say about dynamic libraries? I heard that it completely ignores them (for some reason) - if it's true, why so?
What does C++ standard say about dynamic libraries?
176 Views Asked by blonded04 At
1
There are 1 best solutions below
Related Questions in C++
- How to immediately apply DISPLAYCONFIG_SCALING display scaling mode with SetDisplayConfig and DISPLAYCONFIG_PATH_TARGET_INFO
- Why can't I use templates members in its specialization?
- How to fix "Access violation executing location" when using GLFW and GLAD
- Dynamic array of structures in C++/ cannot fill a dynamic array of doubles in structure from dynamic array of structures
- How do I apply the interface concept with the base-class in design?
- File refuses to compile std::erase() even if using -std=g++23
- How can I do a successful map when the number of elements to be mapped is not consistent in Thrust C++
- Can std::bit_cast be applied to an empty object?
- Unexpected inter-thread happens-before relationships from relaxed memory ordering
- How i can move element of dynamic vector in argument of function push_back for dynamic vector
- Brick Breaker Ball Bounce
- Thread-safe lock-free min where both operands can change c++
- Watchdog Timer Reset on ESP32 using Webservers
- How to solve compiler error: no matching function for call to 'dmhFS::dmhFS()' in my case?
- Conda CMAKE CXX Compiler error while compiling Pytorch
Related Questions in DYNAMIC-LINKING
- Making binary depend on the correct `libpthread`
- Unable to load library from custom paths during compilation
- Segmentation fault while loading library with LD_LIBRARY_PATH
- Is mixing dynamic and shared libraries a good idea when creating an ODBC Driver?
- Executable searching for the linked library in different path than the one set using LD_LIBRARY_PATH
- Where is the order in which ELF relocations are applied specified?
- Cmake: Specify custom path to STL library (libstdc++)
- Visual Studio 2022 - how to link an .obj file residing somewhere else on the system?
- Unable to dynamically link on Alpine
- Statically include libc in c++ program with gcc without using -static option
- How to set BOOST_ALL_DYN_LINK for Cython build of my library interface on Windows 10
- What exactly is static variable behaviour in multiple linkeage of a library that contains it in C++?
- Using patchelf to change the SONAME of libGLdispatch.so breaks its functionality
- What is the linux command that gives the paths to libraries for linking during c++ compilation?
- build static curl executable from source
Related Questions in DYNAMIC-LIBRARY
- Link shared library through makefile
- how to test .dll on Linux
- Is mixing dynamic and shared libraries a good idea when creating an ODBC Driver?
- Link OpenCV library to a Scala project
- Is there a better way to define multiple function definitions when using a dynamic library?
- What does C++ standard say about dynamic libraries?
- Exposing common API from main program *to* dylib in Rust
- failed to find version script file when linking a dynamic library by using bazel cluster
- What is a real purpose of dynamic linking in c++?
- use shared library with eclipse on windows
- I want to release a C dynamic library for linux. At run time, will it be compatible with any linux version?
- How can I use a library without a header file path in cmake?
- My cygwin gcc report conflicting types error when building dynamic link library using JNI
- What happens when a shared object is loaded
- How to enter the source file of a dynamic lib (.so) when debugging
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There are, effectively, just 2 major pitfalls with dynamic libraries, where you can trivially break the assumptions made in the C++ Standard such that it doesn't match the abstract machine:
Violating the "One Definition" rule: e.g., you have managed to dynamically link two libraries with different implementations of the same symbol; each one has, for some reason, preferred local linkage and, depending on who calls, a different implementation is used. The C++ spec still tells you what you are allowed to do, even though the compiler, linker and dynamic loader can be easily configured to violate that rule.
In this case, the default you have, e.g., on Linux systems with
ld-linux + gcc + ld, with public visibility for all symbols, means that all symbols are resolved by the dynamic loader at runtime, which actually fits the description of the abstract machine.Unfortunately this default is not preferable at all, for performance reasons. Limiting visibility of symbols is the prerequisite to allow even the most basic forms of inlining optimizations.
Loading and unloading libraries at unexpected times: This means pointers (to code and data segments) can become (or remain) invalid at arbitrary times, which doesn't match the abstract state machine at all.
In both cases, it's still your responsibility as a developer to ensure that you stay within the bounds of the abstract machine, and not cause any observable behavior which would contradict it.
So much for the theory.
The reality is that, in both cases, most dynamic libraries actually don't even try to act as if the system/process as a whole was compliant with the C++ abstract machine.
Instead, C++ is only expected to be fully functional within each dynamic library, while the entire external interface is entirely aware of dynamic linkage, symbol visibility etc., and avoids any C++ features which could potentially expose undefined behavior on the boundaries. Each library – on its own – acts in compliance with the abstract machine.