shared-libraries

How to initialize a shared library on Linux

拜拜、爱过 提交于 2019-11-30 03:53:48
I am developing a shared library using C++ under Linux, and I would like this library to use log4cxx for logging purposes. However, I'm not sure how to set this up. For log4cxx to work, I need to create a logger object. How can I make sure this object is created when my library is loaded? I suspect that it will be easiest to create the logger object as a global variable and then use it from any of the source files of my library, declaring it as extern in the headers. But how can I have the logger created automatically once an application connects to the library? I know that in DLLs for Windows

Shared libraries memory space

余生长醉 提交于 2019-11-30 03:52:43
Does a C++ shared library have its own memory space? Or does it share the caller process' one? I have a shared library which contains some classes and wrapper functions. One of this wrapper function is kinda: libXXX_construct() which initializes an object and returns the pointer to the said object. Once I use libXXX_construct() in a caller program where is the object placed?Is it in the "caller" memory space or is it in the library's memory space? A linked instance of the shared library shares the memory space of the instance of the executable that linked to it, directly or indirectly. This is

list exported functions from dll with ctypes

匆匆过客 提交于 2019-11-30 03:13:40
Is there any way to know which functions are exported from the dll through python foreign function library ctypes ? And if possible to know details about the exported functions through c types . If yes, could someone provide a snippet of code? I don't think ctypes offers this functionality. On Windows with visual studio: DUMPBIN -EXPORTS XXX.DLL Or for mingw on windows: objdump -p XXX.dll xealits If you are on Linux, there is a handy utility nm to list the content of a shared library (there is always a handy utility on Linux, especially for C stuff). Here is the question about it. You use it

GCC -m32 flag: /usr/bin/ld: skipping incompatible

流过昼夜 提交于 2019-11-30 03:00:29
问题 On 64 bit host I am trying to build shared libraries with -m32 option. Is it possible for these libraries to be linked with regular 64 bit libraries? I am doing something like this: g++ -m32 -shared source.cpp -l 64_bit_library.so -o 32_bit_library.so and getting error messages like this: /usr/bin/ld: skipping incompatible 64_bit_library.so So my question is: how 64_bit_library.so and 32_bit_library.so should be compiled on 64 bit host, to make it possible for 32_bit_library.so to be linked

Loading time for shared libraries vs static libraries

一世执手 提交于 2019-11-30 02:28:11
I have a question on shared libraries vs static libraries loading time. Assume that i have a executable foo.exe which uses liba, libb, libc. Also at a given time there are more than 10 instances of the executable running on the machine. Now if the above 3 libraries were shared libraries : 1st Insance is loaded into RAM : The time taken will be time taken by main() of foo.exe to be loaded memory (assuming its negligible) + time to load liba + time to load libb + time to load libc 2nd instance is started : Now assume a second instance of this executable is run. Since all libraries are already

Recommendation for C++ wrapper for cross platform in-process dynamic library bindings (i.e. a lightweight, high performance COM or CORBA) [closed]

泪湿孤枕 提交于 2019-11-30 02:24:32
We're developing an application that will have a plug-in "architecture" to allow consumers of the app to provide their own proprietary algorithms. (We will basically have a set of parsers and allow third parties to provide their own as well) The domain space requires very high performance, so out-of-process bindings are not going to work and we'd rather leave the heavyweight things like CORBA and COM alone. Basically we're looking for a simple cross-platform wrapper around: load library from a relative path provide a mapping of the particular dll/.so to some configuration/name do some

How to hide the exported symbols name within a shared library

萝らか妹 提交于 2019-11-30 02:07:30
For VC, I can write a DEF file and use the 'NONAME' directive to leaving only the ordinal number in dll's export table. How could I do the same thing with gcc and ELF format shared library? Or, is there something equivalent in ELF shared library like the ordinal number in a PE format DLL? If not, how could I hide the exported symbol's name within a shared library? ====================================== UPDATE: Some additional descriptions: In Windows, you can export a function by only place a integer ID (the ordinal) with an empty name. To show it, the normal layout for a dll's export table

Creating shared libraries in C++ for OSX

会有一股神秘感。 提交于 2019-11-30 01:38:55
问题 I just started programming in C++ and I've realized that I've been having to write the same code over and over again(mostly utility functions). So, I'm trying to create a shared library and install it in PATH so that I could use the utility functions whenever I needed to. Here's what I've done so far :- Create a file utils.h with the following contents :- #include<iostream> #include<string> std::string to_binary(int x); Create a file utils.cpp with the following contents :- #include "utils.h"

How can LD_LIBRARY_PATH be changed within CMake?

六月ゝ 毕业季﹏ 提交于 2019-11-30 00:24:53
问题 I have a local shared library which is not in $LD_LIBRARY_PATH. I want to run my executable, but since it cannot find the shared library in the system folders, it outputs "error while loading shared libraries". A possible fix for this is to export a new LD_LIBRARY_PATH containing the local library folder. How can I export automatically this environment variable within CMake? 回答1: If your shared lib is not build in the same CMake project of your executable, you can use the CMake rpath handling

How to link to shared lib from shared lib with relative path?

99封情书 提交于 2019-11-30 00:11:24
I'm working on a Firefox plugin that uses external libraries to render 3D graphics on the browser. The problem is that I want the plugin to use external libraries packed with it without changing the LD_LIBRARY_PATH variable. The libraries are installed in a position relative to the plugin (a shared library too), while the actual executable (i.e. the browser) can be located somewhere entirely else. I'm testing it on Ubuntu (no problem at Windows version of the plugin) My dependencies are OpenSceneGraph libraries and static compilation will make the plugin really big (not an option if there is