shared-libraries

How to call a function from a shared library?

僤鯓⒐⒋嵵緔 提交于 2019-12-17 17:38:24
问题 What is the easiest and safest way to call a function from a shared library / dll? I am mostly interested in doing this on linux, but it would be better if there were a platform-independent way. Could someone provide example code to show how to make the following work, where the user has compiled his own version of foo into a shared library? // function prototype, implementation loaded at runtime: std::string foo(const std::string); int main(int argc, char** argv) { LoadLibrary(argv[1]); //

Alternatives to dlsym() and dlopen() in C++

泪湿孤枕 提交于 2019-12-17 17:32:17
问题 I have an application a part of which uses shared libraries. These libraries are linked at compile time. At Runtime the loader expects the shared object to be in the LD_LIBRARY_PATH , if not found the entire application crashes with error "unable to load shared libraries".Note that there is no guarantee that client would be having the library, in that case I want the application to leave a suitable error message also the independent part should work correctly. For this purpose I am using

use static class variable/function across dlls

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 17:08:59
问题 I need help access global functions across DLLs/main program. I have a class Base Base.h #ifdef MAIN_DLL #define DECLSPEC __declspec(dllexport) #else #define DECLSPEC __declspec(dllimport) #endif class Base { private: DECLSPEC static Filesystem * filesystem; DECLSPEC static Logger * logger; DECLSPEC static System * system; public: static void setFilesystem(Filesystem * filesystem_); static void setApplication(Application * application_); static void setLogger(Logger * logger_); static void

PHP cannot load shared libraries

偶尔善良 提交于 2019-12-17 16:55:19
问题 I'm new to posting on this forum. Hopefully I don't make any social mistakes here. I have: Linux system (64 bit) php compiled and installed with the following options: ./configure --enable-maintainer-zts --with-pdo-mysql --with-mysqli=mysqlnd --prefix=/etc/httpd/php --with-gd --with-config-file-path=/etc/httpd/php --disable-cgi --with-zlib --with-gettext --with-gdbm --enable-zip --enable-mbstring --with-zlib-dir=/usr/include --with-libxml-dir=/usr/lib64 --with-mcrypt=/usr/lib64 --with-jpeg

How can a shared library (.so) call a function that is implemented in its loading program?

随声附和 提交于 2019-12-17 15:29:06
问题 I have a shared library that I implemented and want the .so to call a function that's implemented in the main program which loads the library. Let's say I have main.c (executable) which contains: void inmain_function(void*); dlopen("libmy.so"); In the my.c (the code for the libmy.so) I want to call inmain_function : inmain_function(NULL); How can the shared library call inmain_function regardless the fact inmain_function is defined in the main program. Note: I want to call a symbol in main.c

How to build OpenSSL as unversioned shared lib for Android?

感情迁移 提交于 2019-12-17 13:24:13
问题 I am trying to build the latest OpenSSL for Android following Compiling the latest OpenSSL for Android. I manage to build the static libs. However I try to compile the shared libs. To do so I run: ./Configure android-armv7 shared This compiles. Problem is that this creates a versioned lib like libssl.so.1.0.0, which is not supported by Android. Just rename does not do because of SONAME is still pointing to the versioned filename. Different problem I have is when trying to the create the libs

How to build OpenSSL as unversioned shared lib for Android?

风格不统一 提交于 2019-12-17 13:23:23
问题 I am trying to build the latest OpenSSL for Android following Compiling the latest OpenSSL for Android. I manage to build the static libs. However I try to compile the shared libs. To do so I run: ./Configure android-armv7 shared This compiles. Problem is that this creates a versioned lib like libssl.so.1.0.0, which is not supported by Android. Just rename does not do because of SONAME is still pointing to the versioned filename. Different problem I have is when trying to the create the libs

Executing a shared library on Unix

不羁岁月 提交于 2019-12-17 10:49:15
问题 Some Unix shared libraries provide an output when called from the command line as if they were executables. For example: $ /lib/libc.so.6 GNU C Library stable release version 2.13, by Roland McGrath et al. Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 4.5.2. Compiled on a Linux 2.6.37 system on 2011-01-18. [...] In

library path when dynamically loaded?

扶醉桌前 提交于 2019-12-17 10:33:49
问题 How can I get the path of the shared library from within the library itself? In other words, let's say that library X is loaded using dlopen() , how can I get access to the path that was used to load the said library from within the library itself? Note that I cannot have the agent that loaded the library in the first place hand me this parameter. UPDATED: Here is way that works with static variables: std::string wdir; namespace { class dynamic_library_load_unload_handler { public: dynamic

ctypes error: libdc1394 error: Failed to initialize libdc1394

放肆的年华 提交于 2019-12-17 10:15:57
问题 I'm trying to compile my program to a shared library that I can use from within Python code using ctypes. The library compiles fine using this command: g++ -shared -Wl,-soname,mylib -O3 -o mylib.so -fPIC [files] `pkg-config --libs --cflags opencv` However, when I try and import it using ctypes from ctypes import * mylib = CDLL("/path/to/mylib.so") print mylib.test() // Expected output: Hello World I get the following error: libdc1394 error: Failed to initialize libdc1394 What's going on? 回答1: