Dynamic linking is a system which allows libraries to remain separate from programs until loaded, contrast static linking.
Questions tagged [dynamic-linking]
1607 questions
502
votes
19 answers
When to use dynamic vs. static libraries
When creating a class library in C++, you can choose between dynamic (.dll, .so) and static (.lib, .a) libraries. What is the difference between them and when is it appropriate to use which?

Morten Christiansen
- 19,002
- 22
- 69
- 94
489
votes
16 answers
Static linking vs dynamic linking
Are there any compelling performance reasons to choose static linking over dynamic linking or vice versa in certain situations? I've heard or read the following, but I don't know enough on the subject to vouch for its veracity.
1) The difference in…

Eloff
- 20,828
- 17
- 83
- 112
294
votes
5 answers
What do 'statically linked' and 'dynamically linked' mean?
I often hear the terms 'statically linked' and 'dynamically linked', often in reference to code written in C, C++ or C#. What are they, what exactly are they talking about, and what are they linking?

UnkwnTech
- 88,102
- 65
- 184
- 229
195
votes
5 answers
What do linkers do?
I've always wondered. I know that compilers convert the code you write into binaries but what do linkers do? They've always been a mystery to me.
I roughly understand what 'linking' is. It is when references to libraries and frameworks are added to…

Kristina
- 15,859
- 29
- 111
- 181
188
votes
2 answers
Telling gcc directly to link a library statically
It feels strange to me to use -Wl,-Bstatic in order to tell gcc which libraries I want to link with statically. After all I'm telling gcc directly all other information about linking with libraries (-Ldir, -llibname).
Is it possible to tell the gcc…

Elazar Leibovich
- 32,750
- 33
- 122
- 169
181
votes
3 answers
What happens to global and static variables in a shared library when it is dynamically linked?
I'm trying to understand what happens when modules with globals and static variables are dynamically linked to an application.
By modules, I mean each project in a solution (I work a lot with visual studio!). These modules are either built into…

Raja
- 2,846
- 5
- 19
- 28
170
votes
9 answers
"No such file or directory" error when executing a binary
I was installing a binary Linux application on Ubuntu 9.10 x86_64. The app shipped with an old version of gzip (1.2.4), that was compiled for a much older kernel:
$ file gzip
gzip: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),…

Lorin Hochstein
- 57,372
- 31
- 105
- 141
162
votes
4 answers
Call Go functions from C
I am trying to create a static object written in Go to interface with a C program (say, a kernel module or something).
I have found documentation on calling C functions from Go, but I haven't found much on how to go the other way. What I've found…

beatgammit
- 19,817
- 19
- 86
- 129
100
votes
2 answers
What does @plt mean here?
0x00000000004004b6 : callq 0x400398
Anyone knows?
UPDATE
Why two disas printf give me different result?
(gdb) disas printf
Dump of assembler code for function printf@plt:
0x0000000000400398 : jmpq …

gdb
- 7,189
- 12
- 38
- 36
93
votes
5 answers
Print rpath of an executable on macOS
I want to change the rpath of an executable using install_name_tool, but I can't figure out what the rpath is right now. install_name_tool requires both the old and the new rpath's to be given on the commandline. What command can I use to print the…

staticfloat
- 6,752
- 4
- 37
- 51
83
votes
3 answers
Is it OK to use DYLD_LIBRARY_PATH on Mac OS X? And, what's the dynamic library search algorithm with it?
I read some articles discouraging of the use of DYLD_LIBRARY_PATH, as the the path of dynamic library should be fixed using -install_name, @rpath, and @loader_path.
In terms of making a program that runs both on Linux and Mac OS X,…

prosseek
- 182,215
- 215
- 566
- 871
68
votes
2 answers
Force GCC to notify about undefined references in shared libraries
I have a shared library that is linked with another (third-party) shared library. My shared library is then loaded using dlopen in my application. All this works fine (assuming files are in the proper path etc).
Now, the problem is that I don't even…

Fredrik Ullner
- 2,106
- 2
- 22
- 28
67
votes
2 answers
Why does gcc not implicitly supply the -fPIC flag when compiling static libraries on x86_64
I've had numerous problems compiling shared objects that link statically against static libraries. This problem only shows up on x84_64 platforms. When doing the same compilation work on x86_32 I do not have any problems.
Perhaps this is a OS…

Hassan Syed
- 20,075
- 11
- 87
- 171
63
votes
1 answer
Weak symbol aliases on OS X similar to those on Linux, or a closest equivalent?
What I do
When writing shared libraries for Linux, I tend to pay attention to relocations, symbol visibility, GOT/PLT etc.
When applicable, I am trying to avoid calling PLT stubs when functions from the same library call each other. For example,…
user405725
60
votes
2 answers
iOS is it a static or a dynamic framework?
This might sound like a silly question but If you have a thirdParty.framework file, can you tell if it's static or dynamic? I mean, do they look different if you look inside?

Hadi tavakoli
- 1,267
- 2
- 16
- 30