Questions tagged [dynamic-library]

Compiled binaries capable to be loaded in the process address space in runtime.

Dynamic Libraries are compiled binaries capable of being loaded/unloaded into/from the process address space at runtime.

In the Unix world, they are called shared libraies; in the Windows world, they are known as DLLs (dynamically-loadable libraries).

They can be loaded simultaneously into multiple processes, saving RAM and disk space.

Their file format is similar to, or even the same as, that of binary executables.

484 questions
1
vote
1 answer

Static library & Dynamic library - more C++ fun

Let's say I want to create a dynamic library dynamic.so, but my code references a function that exists in some other, static library static.a. Naturally, if I compile and link with g++ and the -sharedoption, dynamic.so will expect the referenced…
Thomas
  • 17,016
  • 4
  • 46
  • 70
1
vote
1 answer

Not Understanding Why I am Getting a Segmentation Fault

When I pass an array into a function in a dynamic library with the signature: void itoa(int n, char s[]); and calling it from my main function: int main(int argc, char *argv[]) { if (argc > 1) { char *arg = argv[1]; …
Matthew Hoggan
  • 7,402
  • 16
  • 75
  • 140
1
vote
0 answers

What happens when a shared object is loaded

I have written a pam module using Golang and C, similar to https://github.com/uber/pam-ussh. I am noticing an issue with the signal handler of Golang even though my PAM module is never called to authenticate. In strace output, I can see that all…
KeepAsking
  • 11
  • 1
1
vote
1 answer

What is the C++ way of interpreting the void* returned by dlsym as a pointer-to-function?

Assume a dynamic library exports a function, e.g. of type void(), named foo. A client code could then make use of it like in the following snippet (assuming foo is exposed via extern "C" void foo(); for simplicity) #include "Foo.hpp" // defines the…
Enlico
  • 23,259
  • 6
  • 48
  • 102
1
vote
1 answer

Why should I need libprofiler.so.0

I am using google prof tools, and link my app with -lprofiler, but when I run this program: error while loading shared libraries: libprofiler.so.0: cannot open shared object file: No such file or directory on the contrary, I link with -ltcmalloc…
Shawn
  • 1,441
  • 4
  • 22
  • 36
1
vote
1 answer

Dynamic linking: offset value used to index relocation table

I'm trying to understand dynamic linking process...the call to a library function (let's call it func) passes through the plt table. I know when the symbol is not yet relocated the call of the function passes from plt table which contains an…
MirkoBanchi
  • 2,173
  • 5
  • 35
  • 52
1
vote
1 answer

Java on macOS: "cannot open JVM dynamic library" despite the file exists

when starting a java program I get the following error message: Cannot open JVM dynamic library Dynamic library location: /Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home/lib/libjli.dylib But the file exists: -rw-r--r-- 1…
tab
  • 11
  • 1
1
vote
2 answers

How do you detect the size of a dynamic library(shared object) in the current process?

We could use GetModuleInformation to get the information of a loaded dynamic library on Windows platforms, including its base address and size. And, GetModuleHandleEx can take an address as the input and returns the module's handle. So basically,…
amanjiang
  • 1,213
  • 14
  • 33
1
vote
1 answer

Unable to load dynamic library in a .NET app on Linux

Unable to load dynamic library on Linux I built a project on Mac OS and the output was a libmylibrary.so and libmylibrary.dylib files. I copied the .dylib into a Visual Studio Console project and was able to load and invoke the functions of the…
Sahil Khanna
  • 4,262
  • 8
  • 47
  • 72
1
vote
0 answers

On Mac, is it possible to create two shared lib that depends on each other?

On Linux I can create two coupled shared library lib1 lib2. Since linking happens on a latter stage, so it is fine. But on Mac, dylib are "linked". which means that creating lib1 would requires lib2 to exists first, which then requires lib1 to…
somebody4
  • 505
  • 4
  • 14
1
vote
1 answer

Access dynamic symbol with hidden visibility attribute using `dlsym`

I have a dynamically linked library that defines __attribute__((visibility("hidden"))) symbol which I need to access. Here is a simplified code shared.c __attribute__((visibility("hidden"))) int hidden_sym[12]; int …
haxscramper
  • 775
  • 7
  • 17
1
vote
2 answers

Xcode: How do I build my .app project also as a Shared Library?

First I am using Xcode 3.2.5 on a MAC OS X 10.6 I have an Cocoa Application project that builds and runs fine. I have some functions in this project that I am exporting out using: #define CORE_EXPORT __attribute__ ((visibility ("default"))) extern…
Michael Wildermuth
  • 5,762
  • 3
  • 29
  • 48
1
vote
1 answer

Why dynamic libraries source code should be compiled with position-independent code?

I'm very confused about position-independent code and its usage for dynamic libraries. I found this good example about -fPIC option of GCC: GCC -fPIC option and I figure out how it works. However, I'm struggling to understand why dynamic libraries…
1
vote
1 answer

`undefined reference` error occurred when linking dynamic c++ lib with CGO

I use dynamic libaray written by c++ in my Go code as following: /* #cgo CFLAGS: -I include #cgo LDFLAGS: -L lib -ldemo #include "demo.h" */ import "C" func main() { C.demo() // demo function in c++ library } The libdemo.so library depends on…
kenticny
  • 507
  • 2
  • 8
  • 20
1
vote
2 answers

undefined symbol: _ZTI13my_plugin_api during Boost::DLL tutorial

I have problem running the very first example of Boost::DLL tutorial. At some point I just copied code from the git repo to be sure I didn't do any mistake. Didn't help. Both executable and shared lib compile and link properly. However, I still get…
Lehu
  • 761
  • 4
  • 14