Shared libraries are libraries that are loaded by programs when they start. A single shared copy of each library is loaded into physical memory and may be used by multiple processes at the same time. This reduces memory use and improves system performance. This tag should never be used alone.
Questions tagged [shared-libraries]
7905 questions
3
votes
1 answer
C portable shared library interface: best practice on primitive types
Problem:
Recently we've encountered the following problem with our C shared library.
The library defines a method like this one:
typedef enum {A, B, C} some_enum;
typedef struct {some_enum e; time_t t; char* data;} request;
void f(request);
We've…

Alexander
- 2,761
- 1
- 28
- 33
3
votes
1 answer
Analog of `os.add_dll_directory` for Linux
I am trying to load a .so library in Python using ctypes. This library has many files in /home/me/my_library. When I load
from ctypes import *
lib = CDLL('/home/me/my_library/main.so')
I get
OSError: not_main.so: cannot open shared object file: No…

user171780
- 2,243
- 1
- 20
- 43
3
votes
4 answers
what is the best way to initialize my global data in shared library?
I have a single class which does all the required initialization.
currently i have declared a global object of this class type, which is being instantiated on library load.
I've seen other ways, like delaring
BOOL APIENTRY DllMain
entry point for…

sramij
- 4,775
- 5
- 33
- 55
3
votes
0 answers
GCC installed inside conda ignores LIBRARY_PATH?
I installed GCC into a conda environment:
conda create -n gccenv gcc_linux-64=8.4.0 gxx_linux-64=8.4.0
When I set LIBRARY_PATH, it is only picked up by the system GCC however:
conda activate gccenv
export LIBRARY_PATH=/foo/bar
/usr/bin/g++…

pallgeuer
- 1,216
- 1
- 7
- 17
3
votes
0 answers
`std::type_index` across shared libraries
I have noticed that, at least under c++17 ISO with g++, std::type_index seems to reliably match equality in the case of polymorphic dynamically loaded classes through dlsym. This seems to enable a nice little runtime validation of interfaces before…

lurscher
- 25,930
- 29
- 122
- 185
3
votes
2 answers
How to use Apollo/Graphql hooks within external React.js component library
I have 3 React.js projects and I'm trying to consolidate the reused components across all 3 projects into one shared component library.
This component library is hosted on Github and imported into all 3 projects through the package.json file like…

bdready
- 31
- 1
3
votes
0 answers
First steps to adding a static library to c++/ROS (CMake)
I'm trying to add a static library to my C++/ROS project and having trouble wondering where to start. I have the project currently working with a CMake file to build it and have downloaded (and can build) an external static library that I want to…

TheAddie
- 73
- 1
- 6
3
votes
1 answer
The problem of link order when dynamic link libraries depend on each other
Sorry for my bad english.
During GCC compilation, if main.o depends on liba.so, and liba.so depends on libb.so
Then you should link liba.so first and then libb.so. Conversely, an error will occur
The reasons I learned are:
The compiler will traverse…

velscode
- 75
- 3
3
votes
0 answers
ffi-napi How to accept a struct containing a char array as the return type?
I am passing a callback to a function in C++. This callback must accept a struct defined in the C++ code that contains a char array.
I looked at Call C++ dll with struct containing char array from Node.js, which discusses how to pass a struct…

DOM
- 53
- 1
- 8
3
votes
1 answer
Changing the variable defined in shared library in my program doesn't get reflected seen from the shared library
Trying to test a simple case where a global variable defined in a shared library is set by a program and used by the shared library, I saw a strange problem. Here are the program codes.
bar.cpp
#include
#include
extern "C"…

Chan Kim
- 5,177
- 12
- 57
- 112
3
votes
0 answers
How does rule-of-zero affect shared libraries with hidden visibility?
NOTE: The question is at the bottom.
I'm trying to understand the problems that can occur if using rule-of-zero with shared libraries and derived types.
In the demonstration below, DerivedType is compiled with rule-of-zero or not depending on a…

steveire
- 10,694
- 1
- 37
- 48
3
votes
2 answers
Access to another angular project
I'm developing an app which enables users to theme the application to their preferences. (named App-A for better understanding)
I need to have access to certain parts of App-B, which is the main application. I want to show a preview of a part of…

internethulk
- 92
- 2
- 15
3
votes
0 answers
Error while loading shared libraries when running ghc or ghci
/home/surya/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/bin/ghc: error while loading shared libraries: libtinfo.so.6: cannot open shared object file: No such file or directory
while running ghc or ghci in terminal
Ghc version:8.10.4
Ghcup version:The GHCup…

Surya Prakash
- 91
- 6
3
votes
1 answer
Leaderboard doesn't add in the screen cocos2d
I used the code below to show the Leaderboard but all i got it the console this
cocos2d: surface size: 480x320
the code:
- (void)showLeaderboardForCategory:(NSString *)category
{
// Only execute if OS supports Game Center & player is logged…

Bobj-C
- 5,276
- 9
- 47
- 83
3
votes
1 answer
Does everything that may end up in a shared library always need to be compiled with -fPIC?
I'm building a shared library. I need only one function in it to be public.
The shared library is built from a few object files and several static libraries. The linker complains that everything should be build with -fPIC. All the object files and…

Blue Nebula
- 932
- 4
- 9