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:

12672 questions
664
votes
16 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,236
  • 5
  • 26
  • 41
496
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
  • 13,866
  • 12
  • 34
  • 30
451
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
  • 57,181
  • 57
  • 223
  • 390
308
votes
4 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
  • 17,212
  • 12
  • 64
  • 137
251
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
  • 79,308
  • 64
  • 178
  • 223
249
votes
5 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
  • 70,450
  • 50
  • 199
  • 310
231
votes
17 answers

g++ undefined reference to typeinfo

I just ran across the following error (and found the solution online, but it's not present in Stack Overflow): (.gnu.linkonce.[stuff]): undefined reference to [method] [object file]:(.gnu.linkonce.[stuff]): undefined reference to `typeinfo…
cdleary
  • 63,281
  • 49
  • 155
  • 190
228
votes
14 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
  • 7,966
  • 10
  • 44
  • 56
181
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
  • 93,094
  • 111
  • 230
  • 334
174
votes
7 answers

ld cannot find an existing library

I am attempting to link an application with g++ on this Debian lenny system. ld is complaining it cannot find specified libraries. The specific example here is ImageMagick, but I am having similar problems with a few other libraries too. I am…
maxpenguin
  • 4,709
  • 6
  • 26
  • 21
167
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
  • 17,730
  • 25
  • 86
  • 117
159
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
  • 14,773
  • 14
  • 98
  • 115
150
votes
6 answers

Linking static libraries to other static libraries

I have a small piece of code that depends on many static libraries (a_1-a_n). I'd like to package up that code in a static library and make it available to other people. My static library, lets call it X, compiles fine. I've created a simple sample…
Jason Sundram
  • 10,998
  • 19
  • 67
  • 84
149
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
  • 30,136
  • 27
  • 116
  • 161
147
votes
4 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 Brooks
  • 14,589
  • 25
  • 101
  • 178
1
2 3
99 100