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
55
votes
4 answers

What causes linker warning "MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG"?

Some projects in my solution produce this linker warning: MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance I'm using Visual Studio 2013 Update 3. I…
Scott Langham
  • 58,735
  • 39
  • 131
  • 204
55
votes
11 answers

What do C and Assembler actually compile to?

So I found out that C(++) programs actually don't compile to plain "binary" (I may have gotten some things wrong here, in that case I'm sorry :D) but to a range of things (symbol table, os-related stuff,...) but... Does assembler "compile" to pure…
lamas
  • 4,528
  • 7
  • 38
  • 43
55
votes
7 answers

LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification

I recently converted a multi-project Visual Studio solution to use .dlls instead of .libs for each of the projects. However, I now get a linker warning for each project as stated in the example. MSDN didn't serve to be all that helpful with this. …
Mark
  • 6,123
  • 13
  • 41
  • 52
55
votes
6 answers

ldconfig error:"is not a symbolic link" when using Linux loader

When running: sudo /sbin/ldconfig the following error appears: /sbin/ldconfig: /usr/local/lib/ is not a symbolic link When I run the file command, the below appears: file /usr/local/lib/ /usr/local/lib/: directory Inside…
Rodrigo Gurgel
  • 1,696
  • 2
  • 15
  • 32
54
votes
3 answers

What are the differences between a compiler and a linker?

What is the difference between a compiler and a linker in C?
smruti
  • 541
  • 1
  • 4
  • 4
53
votes
3 answers

C++ : Difference between linking library and adding include directories

Pretty much title sums it up. I'm not sure the difference between the two if i'd like to use a library. Thanks!
Setheron
  • 3,520
  • 3
  • 34
  • 52
53
votes
2 answers

What's the difference between `-rpath-link` and `-L`?

The man for gold states: -L DIR, --library-path DIR Add directory to search path --rpath-link DIR Add DIR to link time shared library search path The man for bfd ld makes it sort of sound like -rpath-link is used for…
lanza
  • 1,512
  • 2
  • 13
  • 26
53
votes
3 answers

How to link using GCC without -l nor hardcoding path for a library that does not follow the libNAME.so naming convention?

I have a shared library that I wish to link an executable against using GCC. The shared library has a nonstandard name not of the form libNAME.so, so I can not use the usual -l option. (It happens to also be a Python extension, and so has no 'lib'…
kbluck
  • 11,530
  • 4
  • 25
  • 25
52
votes
12 answers

Linking against older symbol version in a .so file

Using gcc and ld on x86_64 linux I need to link against a newer version of a library (glibc 2.14) but the executable needs to run on a system with an older version (2.5). Since the only incompatible symbol is memcpy (needing memcpy@GLIBC_2.2.5 but…
PlasmaHH
  • 15,673
  • 5
  • 44
  • 57
52
votes
1 answer

Can the linker inline functions?

In the file file1.c, there is a call to a function that is implemented in the file file2.c. When I link file1.o and file2.o into an executable, if the function in file2 is very small, will the linker automatically detect that the function is small…
Squall
  • 4,344
  • 7
  • 37
  • 46
52
votes
5 answers

C header files and compilation/linking

I know that header files have forward declarations of various functions, structs, etc. that are used in the .c file that 'calls' the #include, right? As far as I understand, the "separation of powers" occurs like this: Header file: func.h contains…
Aristides
  • 3,805
  • 7
  • 34
  • 41
52
votes
3 answers

Undefined reference error for template method

This has been driving me mad for the past hour and a half. I know it's a small thing but cannot find what's wrong (the fact that it's a rainy Friday afternoon, of course, does not help). I have defined the following class that will hold…
recipriversexclusion
  • 13,448
  • 6
  • 34
  • 45
51
votes
4 answers

How do you link to a specific version of a shared library in GCC

I'm compiling some code which uses libcurl on a Debian Linux system. My dev machine is running Debian 5 but I want the binary to be usable on older Debian 4 systems too. I find that if I specify -lcurl it will link to libcurl.so.4 but Debian 4…
Adam Pierce
  • 33,531
  • 22
  • 69
  • 89
51
votes
6 answers

What's the use of .map files the linker produces?

What is the use of .map files VC++ linker produces when /MAP parameter or "Generate map file" project setting is used? When do I need them and how do I benefit from them?
sharptooth
  • 167,383
  • 100
  • 513
  • 979
51
votes
5 answers

Why is the linker terminating on me? when i build CLang

I am using opensuse, specific the variant on mono's website when you click vmware I get this error. Does anyone know how i might fix it? make[4]: Entering directory `/home/rupert/Desktop/llvm/tools/clang/tools/driver' llvm[4]: Linking Debug+Asserts…
user34537