shared-libraries

How to do versioning of a shared library in Linux?

自古美人都是妖i 提交于 2019-11-28 10:12:47
Windows provides the resource file for version information for an application and DLL. The resource file includes information like version, copyright and manufacturer. We have an shared library and like to add version information. How can we do it on Linux with a shared library? The short version is that you do this via the soname of the library. Read chapter 3 at http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html as well as chapter 3.3 ABI Versioning at http://www.akkadia.org/drepper/dsohowto.pdf Linux uses the following strategy - you (the system maintainer) provide symlinks

Load multiple copies of a shared library

末鹿安然 提交于 2019-11-28 09:58:02
I am running Linux, and I would like to be able to make parallel function calls into a shared library (.so) which is unfortunately not threadsafe (I am guessing it has global datastructures). For performance reasons, I do not want to simply wrap the function calls in a mutex. What I would like to do is to spawn, say 4 threads, and also load 4 copies of the same library into the process memory. Each thread then makes the function calls into its own copy of the library. Unfortunately, dlopen does not allow me to load more one instance of any library. Does anyone know of any method which will

Dependency Walker equivalent for Linux? [duplicate]

泪湿孤枕 提交于 2019-11-28 08:58:14
This question already has an answer here: Hierarchical ldd(1) 4 answers I need a tool to show all the shared library dependencies in some graphical way, not just with ldd on each .so . For MS Windows Dependency Walker works. Is there anything for Linux? . Try binscan or ELF Library Viewer 来源: https://stackoverflow.com/questions/6977298/dependency-walker-equivalent-for-linux

linux dlopen: can a library be “notified” when it is loaded?

大城市里の小女人 提交于 2019-11-28 08:27:12
Is there a way for a shared library to be "notified" when it is loaded? In other words, let's say I use dlopen on a shared library, is there a function that is automatically called (if present) on the shared library (e.g. main?) Libraries should export initialization and cleanup routines using the gcc __attribute__((constructor)) and __attribute__((destructor)) function attributes. See the gcc info pages for information on these. Constructor routines are executed before dlopen returns (or before main() is started if the library is loaded at load time). Destructor routines are executed before

Difference between using java.library.path and LD_LIBRARY_PATH

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 08:25:21
Is there a difference between setting the JVM argument -Djava.library.path=/path at JVM start and setting the Linux environment variable export LD_LIBRARY_PATH=/path before the JVM is started? What are the advantages/disadvantages of the two approaches? The first form -Djava.library.path=/path will be handled in java bytecode level, System.loadLibrary will call Runtime.loadLibary , then will call java/lang/ClassLoader.loadLibrary . In the function call ClassLoader.loadLibrary , the system property java.library.path will be checked to get the full path of the library and pass this full path to

make gdb load a shared library from a specific path

ⅰ亾dé卋堺 提交于 2019-11-28 08:04:15
问题 I got a core while executing an application and I saved the executable, the corefile and a shared library which the application use in /tmp to check them later. I then modified the library, rebuilt it and started the executable again. Now when I am trying to debug the core, gdb is loading the shared library from its original path and not from the directory /tmp where I saved the original library. For example, the original path was /opt/mydir/lib/libmylib.so.0 . gdb is loading this shared

Get functions names in a shared library programmatically

霸气de小男生 提交于 2019-11-28 07:15:15
问题 Can I get list of all functions names from a shared library (Linux only) programmatically when I am using dl_open() ? I want something like this: std::vector<std::string> list_all_functions(void *dl) { //... what can I do here? } int main() { void * dl = dl_open("./mylib.so", RTLD_NOW); auto functions = list_all_functions(dl); //... dl_close(dl); return 0; } Example library (mylib.so) Header (.h): extern "C" { int sum (int a, int b); } Source (.c): int sum (int a, int b) { return a + b; }

Main Program and Shared Library initializes same static variable in __static_initialization_and_destruction_0

流过昼夜 提交于 2019-11-28 07:03:47
Does anyone know why a library initialized within dlopen() would initialize a static variable owned by the main program. Both the main program and shared library have a copy of the static variable, but for some reason the shared library re-initializes the main program's copy of the static variable and destructs it, causing a segfault when the main program attempts to destruct it. Is this a case of bad name mangling in the symbol table? This is a case where the runtime linker only wants a single active copy of a symbol in a process. If both a shared object and the executable have a copy of the

How can I share library between two program in c

此生再无相见时 提交于 2019-11-28 06:11:49
问题 I want to use same library functions (i.e. OpenSSL library ) in two different programs in C for computation. How can I make sure that both program use a common library , means only one copy of library is loaded into shared main memory and both program access the library from that memory location for computation? For example, when 1st program access the library for computation it is loaded into cache from main memory and when the 2nd program wants to access it later , it will access the data

Linking shared library in linux kernel

瘦欲@ 提交于 2019-11-28 05:08:39
问题 This question was migrated from Unix & Linux Stack Exchange because it can be answered on Stack Overflow. Migrated 4 years ago . I would like to modify the linux kernel. I would like to use functions from a shared library (an .so file) in file kernel/panic.c . Unfortunately I don't know how to compile it. When I put it in to the Makefile I receive the following error: ld: attempted static link of dynamic object . Is there a way to put the shared library file to the Linux kernel or do I need