shared-libraries

Two library of different versions in an application

青春壹個敷衍的年華 提交于 2019-12-05 05:08:57
问题 Consider a scenario where there are two shared library of different version.Consider A.1.so linked to B.so and A.2.so linked to C.so. Now both B.so and C.so are linked to d.exe . When B.so wants to invoke function in A.1.so, it ends up calling function in A.2.so .Because of this , it gives us undefined behaviour. Now I want my B.so invoke only A.1.so.I can only modify A.1.so and B.so , nothing else. Using dlopen() is one of the option, but for using dlopen() , I have to make heavy changes in

Linking libraries with incompatible dependecies

故事扮演 提交于 2019-12-05 04:23:53
I'm working on a C++ project that needs two third party libraries ( libfoo.so and libbar.so ). My operating system is Linux. libfoo.so is dynamically linked to libpng14.so.14 (1.4.8) (EDIT 1) libbar.so seems to be statically linked to an unknwon version of libpng libpng 1.2.8 (EDIT 1) I say "seems to be" because: ldd libbar.so doesn't show nothing about png nm -D libbar.so | grep png_read_png says "004f41b0 T png_read_png" less libbar.so | grep png_read_png says "4577: 004f41b0 738 FUNC GLOBAL DEFAULT 10 png_read_png" When i start my program, it abort: terminate called after throwing an

When exactly is gcc __attribute__((constructor)) run?

て烟熏妆下的殇ゞ 提交于 2019-12-05 04:15:15
Let's say I have an libA.so with GCC constructor. My program "program" depends on libA.so, so when I run it, libA.so gets opened and its constructor is executed. Now, I also have a module, libC.so, which also depends on libA. I run dlopen("libC.so") , which loads libC, and according to my experiments, also executes libA's constructor . Dependencies look like this: libA has the constructor libB also has a constructor libC depends on libA and libB program depends on libA program links libC via dlopen() Now, when I run the program: libA's constructor gets run before main() starts libB's

.so injection under linux: how to locate address of dlopen()?

送分小仙女□ 提交于 2019-12-05 03:57:21
问题 Recently I have become interested in Linux, and am trying to create a program which is capable of injecting a shared object (i.e. .so file, 'dynamically loadable library', "DLL" under Windows.) I know this can be done by setting an environmental variable, but I want to do it on a process which is already running. I already know how to do this under Windows. There are several ways, but generally speaking you can just call LoadLibrary() by creating a remote thread using CreateRemoteThread(). Of

Android – how to load shared library?

柔情痞子 提交于 2019-12-05 03:30:58
I’ve created simplest EXECUTABLE and SHARED_LIBRARY. SHARED_LIBRARY doesn’t get loaded without changing LD_LIBRARY_PATH: # ./hello ./hello link_image[1995]: failed to link ./hello CANNOT LINK EXECUTABLE # LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./hello Hello, world! All code below: first.h #ifndef FIRST_H #define FIRST_H extern int first(int x, int y); #endif /* FIRST_H */ first.c #include "first.h" int first( int x, int y ) { return x + y; } hello.c #include <stdio.h> #include "first.h" int main( int argc, char **argv ) { printf( "Hello, world!\n" ); first( 1000, 24 ); return 0; } Android.mk

Rmpi unable to load shared libraries as non root user

好久不见. 提交于 2019-12-05 02:57:12
I'm having a problem with Rmpi wherein I try to load it and I get this error message: > library('Rmpi') Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/usr/lib64/R/library/Rmpi/libs/Rmpi.so': libmpi.so.0: cannot open shared object file: No such file or directory In addition: Warning message: .Last.lib failed in detach() for 'Rmpi', details: call: dyn.unload(file.path(libpath, "libs", paste("Rmpi", .Platform$dynlib.ext, error: dynamic/shared library '/usr/lib64/R/library/Rmpi/libs/Rmpi.so' was not loaded Error in library("Rmpi") : .First.lib failed for 'Rmpi'

how to make shared library from a static library under ubuntu using gcc

ぃ、小莉子 提交于 2019-12-05 02:40:54
问题 i have a static library libsrp.a, i want to make a shared library libsrp.so from it that contains all symbols . please tell me how to make a .so under ubuntu. thanks 回答1: Recompile the object files contained in libsrp.a with the flag to create position independent code (fpic) as in gcc -fpic -c foo.c gcc -fpic -c bar.c Now you can combine foo.o and bar.o into a shared library as in gcc -shared -o libshared.so foo.o bar.o 回答2: Use the --whole-archive flag: gcc -shared -o libsrp.so -Wl,--whole

Installing the R interpeter and R as a shared library uder the same tree

a 夏天 提交于 2019-12-05 02:21:01
I am a bit confused about how to install R (via compilation) as a shared library. The instructions here ( Rpy2 ) say that I should do the following: # <go to the R source directory> make distclean ./configure --enable-R-shlib make make install but the first make ( make distclean ) would remove any previous installation of R under the same directory tree (e.g. the contents of the bin folder). What if I want to use the same installation for the R interpreter and the shared libraries? For example, say I want to use the interpreter to install R packages, and then the shared library of the

How do I use waf to build a shared library?

依然范特西╮ 提交于 2019-12-05 01:52:43
I want to build a shared library using waf as it looks much easier and less cluttered than GNU autotools. I actually have several questions so far related to the wscript I've started to write: VERSION='0.0.1' APPNAME='libmylib' srcdir = '.' blddir = 'build' def set_options(opt): opt.tool_options('compiler_cc') pass def configure(conf): conf.check_tool('compiler_cc') conf.env.append_value('CCFLAGS', '-std=gnu99 -Wall -pedantic -ggdb') def build(bld): bld.new_task_gen( features = 'cc cshlib', source = '*.c', target='libmylib') The line containing source = '*.c' does not work. Must I specify each

Sharing an Android library between multiple Android apps using Gradle

橙三吉。 提交于 2019-12-05 01:47:18
I have Android apps A and B. I want to extract duplicate code from each into a shared library L. How can I do this using Gradle? I've seen a few permutations of this question asked before, but there were very few answers. The closest/best already-asked question is this one: Multiple Android apps depending on android library with gradle The first answer suggests a parent project that encompasses both apps and the library module. This coupling is undesirable, in part because A, B, and L are in their own Git repository, but also because it would involve having a parent project and build files