Questions tagged [linker]

The linker is part of the toolchain for producing executables from source code written in compiled programming languages. It takes compiled object code in multiple files and produces a single, "linked", executable file from them.

Separately-compiled programming languages such as C and C++ rely on a linker to turn one or more object files and libraries into an executable. The linker resolves undefined symbol references in object files by linking them to symbol definitions in other object files and libraries. The linker also arranges variables and functions to assign them addresses in the final executable,

On Unix-like operating systems the linker is typically named ld and is often invoked automatically by the compiler as the last step in the compilation process.

Books about linkers:

13907 questions
715
votes
18 answers

Embedding DLLs in a compiled executable

Is it possible to embed a pre-existing DLL into a compiled C# executable (so that you only have one file to distribute)? If it is possible, how would one go about doing it? Normally, I'm cool with just leaving the DLLs outside and having the setup…
Merus
  • 8,796
  • 5
  • 28
  • 41
571
votes
9 answers

Why does the order in which libraries are linked sometimes cause errors in GCC?

Why does the order in which libraries are linked sometimes cause errors in GCC?
Landon
  • 15,166
  • 12
  • 37
  • 30
516
votes
5 answers

How does the compilation/linking process work?

How does the compilation and linking process work? (Note: This is meant to be an entry to Stack Overflow's C++ FAQ. If you want to critique the idea of providing an FAQ in this form, then the posting on meta that started all this would be the place…
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
367
votes
5 answers

Difference between shared objects (.so), static libraries (.a), and DLL's (.so)?

I have been involved in some debate with respect to libraries in Linux, and would like to confirm some things. It is to my understanding (please correct me if I am wrong and I will edit my post later), that there are two ways of using libraries when…
Cloud
  • 18,753
  • 15
  • 79
  • 153
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
287
votes
6 answers

Resolving LNK4098: defaultlib 'MSVCRT' conflicts with

This warning: LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library is a fairly common warning in Visual Studio. I'd like to understand the exact reason for it and the right way (if at all) to…
shoosh
  • 76,898
  • 55
  • 205
  • 325
274
votes
18 answers

g++ undefined reference to typeinfo

I just ran across the following error: (.gnu.linkonce.[stuff]): undefined reference to [method] [object file]:(.gnu.linkonce.[stuff]): undefined reference to `typeinfo for [classname]' Why might one get one of these "undefined reference to…
cdleary
  • 69,512
  • 53
  • 163
  • 191
268
votes
16 answers

libpthread.so.0: error adding symbols: DSO missing from command line

When I'm compiling openvswitch-1.5.0, I've encountered the following compile error: gcc -Wstrict-prototypes -Wall -Wno-sign-compare -Wpointer-arith -Wdeclaration-after-statement -Wformat-security -Wswitch-enum -Wunused-parameter…
jaeyong
  • 8,951
  • 14
  • 50
  • 63
209
votes
11 answers

"/usr/bin/ld: cannot find -lz"

I am trying to compile Android source code under Ubuntu 10.04. I get an error saying, /usr/bin/ld: cannot find -lz Can you please tell me how can I fix it? What does cannot find -lz mean? Here's the full error…
michael
  • 106,540
  • 116
  • 246
  • 346
200
votes
6 answers

How to print the ld(linker) search path

What is the way to print the search paths that in looked by ld in the order it searches.
Talespin_Kit
  • 20,830
  • 29
  • 89
  • 135
198
votes
5 answers

What's an object file in C?

I am reading about libraries in C but I have not yet found an explanation on what an object file is. What's the real difference between any other compiled file and an object file? I would be glad if someone could explain in human language.
Pithikos
  • 18,827
  • 15
  • 113
  • 136
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
188
votes
7 answers

How can I link to a specific glibc version?

When I compile something on my Ubuntu Lucid 10.04 PC it gets linked against glibc. Lucid uses 2.11 of glibc. When I run this binary on another PC with an older glibc, the command fails saying there's no glibc 2.11... As far as I know glibc uses…
falstaff
  • 3,413
  • 2
  • 25
  • 26
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
1
2 3
99 100