Problem
The problem with the operating system. The Linux library (a dynamically linked library of shared objects) may depend on other libraries (which may again depend on other libraries, etc.). If these dependent libraries were not resolved correctly, you will get the error you described.
What are shared libraries (sic)
You can create a shared library by taking several object files and linking them together. The compiler saves a lot of metadata when creating a shared library:
- Movement table
- List of exported characters (functions and variables that others can access)
- List of imported characters (functions and variables used by this library from other libraries)
- List of file names of other libraries that can be used to satisfy imported characters
When the library is used, the system loads the library, changes the addresses referenced by the movement table, and then tries to find the imported characters. For them, the system first checks the already loaded libraries. If this does not satisfy all the characters, it tries to find the file names listed in the library and check if a file with that name exists, if it is a valid library and if it exports this character.
Usually the βsystemβ here is a dynamic loader that runs in user space, not kernel space.
How can you check which libraries are used by the program
You can check the contents of the library with commend ldd .
If you want to check the executable executable, try lsof and filter for *.so and also check /proc/[pid]/maps .
How to debug your problem
In your case, hold the program immediately before loading the library (for example, insert a reading from the console or a sleep command). Then check the currently loaded library. You will find that in a good case, a library is already loaded that exports the corresponding symbol. In the event of an error, this library will not load, and the system will try to load the independent library in the next step (for example, another version of the library where the desired character is missing).
Is library order important
Usually not, but it depends on the details. If the same library is needed in a different version, or when the system cannot resolve the shared library in all cases, this can become important. Unfortunately, these problems are quite difficult to debug. On Windows, you have a DLL addon; on Linux, it looks like shared objects. Good luck debugging your problem!