dlopen

Main Program and Shared Library initializes same static variable in __static_initialization_and_destruction_0

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 wh...

Returning a shared library symbol table

For instance: void* sdl_library = dlopen("libSDL.so", RTLD_LAZY); void* initializer = dlsym(sdl_library,"SDL_Init"); Assuming no errors, initializer will point to the function SD_Init in the shared library libSDK.so. However this requires knowing the symbol "SDL_Init" exists. Is it possibly to query a library for all its symbols? E...

On linux, what can cause dlopen to emit SIGFPE?

I have a library of dubious origins which is identified by file as a 32 bit executable. However, when I try to dlopen it on a 32 bit CentOS 4.4 machine, dlopen terminates with SIGFPE. Surely if there was something wrong with the format of the binary then dlopen should be handling an error? So the question is: What kinds of problems ca...

python c extension, problems with dlopen on mac os

I've taken a library that is distributed as a binary lib (.a) and header, written some c++ code against it, and want to wrap the results up in a python module. I've done this here. The problem is that when importing this module on Mac OSX (I've tried 10.5 and 10.6), I get the following error: dlopen(/Library/Python/2.5/site-packages/...

unable to load library at runtime in android application

I m working on android application in which I used JNI for native c code. I build this application on android 2.0 version and ndkr3 and it works fine. Now when I changed the android sdk version 1.5 and api version 3 I faced problems of unable to open library libtest_demo.so. 05-13 16:54:23.603: INFO/dalvikvm(1211): Unable to dlopen(/d...

Dynamic loading of shared objects using dlopen()

Hi, I'm working on a plain X11 app. By default, my app only requires libX11.so and the standard gcc C and math libs. My app has also support for extensions like Xfixes and Xrender and the ALSA sound system. But this feature shall be made optional, i.e. if Xfixes/Xrender/ALSA is installed on the host system, my app will offer extended fu...

Rails 3.0 console won't run

bash-3.2# rails console /opt/local/lib/ruby1.9/1.9.1/irb/completion.rb:9:in `require': dlopen(/opt/local/lib/ruby1.9/1.9.1/i386-darwin10/readline.bundle, 9): Library not loaded: /opt/local/lib/libncurses.5.dylib (LoadError) Referenced from: /opt/local/lib/ruby1.9/1.9.1/i386-darwin10/readline.bundle Reason: no suitable image found. Di...

Undefined symbols GCC / C++ dynamically loadable *.so objects

-I am trying to compile a netsnmp mib and extend the functionality of the snmp agent. When I try to start the daemon and load the shared object (*.so) , the daemon complains about undefined symbols. "dlopen failed: Filename.so: undefined symbol: netsnmp_container_table_row_extract" On further prodding #nm -D -u Filename.so prints out...

C++ Sandboxing dynamic libraries

Hello all, I'm wondering if its at all possible to sandbox a dynamically linked library via dlopen and friends. The aim is to recover from an error within the library without tearing down the hole application e.g SEGFAULT, etc... Anyone had any experience in this area? Cheers ...

Dynamic linking unable to resolve main symbols

I'm trying to dynamically link a module into my program. If I normally compile and link this module then the symbols in it are normally accessible to the C++ via declaring the function prototypes as extern "C". The module itself is a group of fortran functions, that call C++ functions that I have written. When attempting to dynamically ...

dlopen with two shared libraries, exporting symbols

I have a linux shared library, foo.so, which is loaded from an executable using dlopen("foo.so", RTLD_NOW | RTLD_LOCAL). From foo.so I'd like to dlopen another library, bar.so, which references symbols defined in foo.so, but the linker fails to find them. I can't change RTLD_LOCAL to RTLD_GLOBAL, because I don't have the source to the ex...

Debugging a crash when a library is opened via dlopen on OSX

Hello there, I have a problem with a C++ application I've developed which uses dlopen to load user-developed libraries. The application has been used by a variety of people on a variety of linux distros and versions of OSX over the last couple of years and so I'm assuming my usage of dlopen is OK and so is the code that depends on it (y...

jna multiprocess

i'm using jna to glue fortran and java together, and it works great. except for one thing. i have two jvm processes, each of which uses the same shared library. individually, they work fine. calling one, and then the other, also works. but then calling the first one again, segv's. the code doesn't do anything interesting; it copies...

shared object can't find symbols in main binary, C++

I'm experimenting with making a kind of plugin architecture for a program I wrote, and at my first attempt I'm having a problem. Is it possible to access symbols from the main executable from within the shared object? I thought the following would be fine: testlib.cpp: void foo(); void bar() __attribute__((constructor)); void bar(){ fo...

C shared library question

Background: I'm trying to develop a simple game similar to Zelda (NES) in C as a way to learn C. I've come to the conclusion that having all of the game data in a single file is not ideal. So what I'd like to do is break up each "area" into it's own module. This "area" module will describe to the main program its properties, such as ...

dlclose problem

plugin1.cpp: #include <iostream> static class TestStatic { public: TestStatic() { std::cout << "TestStatic create" << std::endl; } ~TestStatic() { std::cout << "TestStatic destroy" << std::endl; } } test_static; host.cpp #include <dlfcn.h> #include <iostream> int main(int argc,char argv*[]) { void* handle = dlop...

dlopen fails with file not found when file is in correct path

I have a library built using libtool which is install into the package's library directory, /usr/local/lib/myprog/libmylib.so. I'm dynamically loading the library in my code with libltdl. When I try to load this library on one machine, it works just fine. On another, with the same build and the library installed on the same location, I g...

how to analysys the coredump that crash in the share library loaded by dlopen?

Gdb only show the function name in the share library that load by system library loader. How to get the crash address in the share library load by dl_open? Thanks. ...