Questions tagged [dlopen]

POSIX function to dynamically load a library or binary into memory

685 questions
6
votes
1 answer

Error loading shared libraries with dlopen()

I am working on a program that loads user-created plugins using dlopen on CentOS. I am running into a problem with a plugin that has dependencies on shared libraries that also have dependencies: libplugin.so -> libservices.so -> libconfig.so Our…
Blake Nelson
  • 85
  • 1
  • 5
6
votes
0 answers

dynamic_cast with dynamically loaded class causes undefined reference

I have a C++ class whose definition is going to be loaded at run-time through dlopen. I can't get it to link though. I get errors saying there is an "undefined reference to typeinfo". The relevant part of the code looks like this: class Interface {…
Elektito
  • 3,863
  • 8
  • 42
  • 72
6
votes
1 answer

How to use dlsym reliably when you have duplicated symbols?

Good evening, I'm currently working on a Plugin system in C++/Linux based on the Plux.net model. To keep it simple, I basicly declare a symbol (lets call it pluginInformation) with extern C (to unmangle) and my plugin manager look for that symbol in…
Velos
  • 63
  • 6
6
votes
1 answer

How can I check a running process to see what shared libraries it is using?

On Linux, I have a C++ application that is using dlopen() to load some shared libraries, but I'm suspicious that the version of the shared library being loaded is not the one I expect because my debugging trace code does not appear to be…
WilliamKF
  • 41,123
  • 68
  • 193
  • 295
6
votes
1 answer

Lua: C++ modules can't reference eachother, undefined symbol

I've created two modules (shared objects) CPU and SaveState as part of an emulator. Both are independently compiled into .so separate files, and loaded at runtime by a Lua script using require(); i.e.: SaveState = require("SaveState") CPU =…
Rena
  • 3,923
  • 3
  • 22
  • 19
6
votes
3 answers

Compile C program using dlopen and dlsym with -fPIC

I am having a problem about a wrong symbol resolution. My main program loads a shared library with dlopen and a symbol from it with dlsym. Both the program and the library are written in C. Library code int a(int b) { return b+1; } int c(int…
user377486
  • 693
  • 2
  • 10
  • 19
5
votes
1 answer

dlopen issue(OSX)

I have a main application which dynamically loads a dylib, from inside that dylib I would like to call exported functions from my main program. I'm using dlopen(NULL,flag) to retrieve my main applications handle and dlsym(handle, symbol) to get the…
Johan_
  • 440
  • 5
  • 14
5
votes
0 answers

RPATH propagation failing for Python bindings

I am building a library (Ubuntu 22) that uses onnxruntime under the hood. In turn, onnxruntime uses CUDA, dynamically loading some dedicated "backend". I build the whole code stack except the CUDA libraries, and none of the libraries have their…
ajc
  • 365
  • 2
  • 18
5
votes
2 answers

Problems with using setenv and then making the dlopen call

I am using setenv to set DYLD_LIBRARY_PATH so when I do a dlopen() it will have the correct paths to find my .dylib, but when I do the dlopen() it doesn't seem to search the paths that I added to DYLD_LIBRARY_PATH. From what I can gather my…
Michael Wildermuth
  • 5,762
  • 3
  • 29
  • 48
5
votes
3 answers

Catching a system call just before control enters a shared library

I have wrapped a number of system call function like write(), open() etc and LD-PRELOAD is used to override the original system calls. Moreover I have defined a few more functions and made this too a shred library. I would like to catch all system…
Lipika Deka
  • 3,774
  • 6
  • 43
  • 56
5
votes
2 answers

dlopen definition of "same library"

According to the dlopen(3) man page: If the same library is loaded again with dlopen(), the same file handle is returned. What does "same library" mean? Same filename? Same path? Same inode? Same SONAME? Something else? How does this behavior…
Void Star
  • 2,401
  • 4
  • 32
  • 57
5
votes
2 answers

Calling dlsym() with a NULL handle doesn't return NULL, but rather returns a random function

My title may not be clear, so allow me to explain. I have a piece of code that goes like this: void* pluginFile = dlopen(fileName, RTLD_LAZY); auto function = dlsym(pluginFile, "ExpectedFunction"); This works fine if dlopen returns the right file.…
JigsawCorp
  • 479
  • 2
  • 6
  • 15
5
votes
2 answers

How to dump an executable SBCL image that uses osicat

I have a simple common lisp server program, that uses the osicat library to interface with the posix filesystem. I need to do this because the system creates symbolic links to files, and uses the POSIX stat metadata, and neither of those things are…
cms
  • 5,864
  • 2
  • 28
  • 31
5
votes
1 answer

Is it possible to merge weak symbols like vtables/typeinfo across RTLD_LOCAL'ly loaded libraries?

For context: I have a Java project that is partially implemented with two JNI libraries. For the sake of example, libbar.so depends on libfoo.so. If these were system libraries, System.loadLibrary("bar"); would do the trick. But since they're…
Tavian Barnes
  • 12,477
  • 4
  • 45
  • 118
5
votes
0 answers

Python import fails with "dlopen: cannot load any more object with static TLS"

I have written a multi-threaded module called fast_nn in Cython and compiled it with the following setup.py: from distutils.core import setup from distutils.extension import Extension from Cython.Build import cythonize import numpy setup( …
Callidior
  • 2,899
  • 2
  • 18
  • 28