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
46
votes
7 answers

GNU gcc/ld - wrapping a call to symbol with caller and callee defined in the same object file

to clarify, my question refers to wrapping/intercepting calls from one function/symbol to another function/symbol when the caller and the callee are defined in the same compilation unit with the GCC compiler and linker. I have a situation resembling…
luis.espinal
  • 10,331
  • 6
  • 39
  • 55
46
votes
2 answers

Can I link a plain file into my executable?

Some frameworks (Qt, Windows, Gtk...) offer functionality to add resources to your binaries. I wonder if it would be possible to achieve this without the framework, since all that is really needed is a symbol to contain the resource's address…
xtofl
  • 40,723
  • 12
  • 105
  • 192
46
votes
2 answers

How to link against boost.system with cmake

I use a cmake generated makefile to compile a c++ file that depends on the boost filesystem library. During the linking process I get the following error: Undefined symbols: "boost::system::get_generic_category()", referenced from: …
Janusz
  • 187,060
  • 113
  • 301
  • 369
45
votes
4 answers

Do ghc-compiled binaries require GHC or are they self-contained?

If a friend wants to run my Haskell binaries, does he have to first install Haskell, or can he immediately run the binary by itself? Is the answer the same on Mac, Windows, and Linux?
mcandre
  • 22,868
  • 20
  • 88
  • 147
45
votes
3 answers

Difference between modules and shared libraries?

The title mostly covers it, what is the difference between a module and a shared library? I just found this distinction in CMake's add_library command, where they say: SHARED libraries are linked dynamically and loaded at runtime. MODULE libraries…
lucas clemente
  • 6,255
  • 8
  • 41
  • 61
45
votes
3 answers

ldconfig equivalent in Mac OS X?

Is there a parallel command to Linux's LDCONFIG for Mac OS X's Terminal?
Tomer Lichtash
  • 9,002
  • 16
  • 55
  • 71
45
votes
6 answers

C++ template, linking error

I have a problem in calling a template class I have. I declared a new type name Array, which is a template; In the .hpp file: template class Array { public: Array(); }; In the .cpp file: template
Boris Raznikov
  • 2,373
  • 10
  • 34
  • 56
44
votes
7 answers

Xcode custom build configuration causes "library/file not found" for static libraries

I have a workspace with a project which links with the static libraries in another project (which is also in the workspace). It's a problem in Kobold2D I haven't been able to resolve, even though I understand the cause, and I suppose it's similar to…
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
44
votes
1 answer

How to fix symbol lookup error: undefined symbol errors in a cluster environment

I'm working on some python code that extracts some image data from an ECW file using GDAL (http://www.gdal.org/) and its python bindings. GDAL was built from source to have ECW support. The program is run on a cluster server that I ssh into. I have…
agnussmcferguss
  • 485
  • 1
  • 4
  • 10
44
votes
1 answer

Libraries in /usr/local/lib not found

I am building an application using a framework called ohNet. After building the framework, there is the possibility to install the framework via make install. By default the libraries are installed inside the /usr/local/[lib|include] folders. ok. I…
Moonlit
  • 5,171
  • 14
  • 57
  • 95
43
votes
5 answers

Why does the general program usually start at 0x8000?

I am not new to bootloader and system SW, but I don't know the origin of the reason why the general program starts at 0x8000. I already know the address 0x8000 has been used as start address in normal C/C++ program. Does the minimum size of the…
OfusJK
  • 676
  • 1
  • 5
  • 13
43
votes
12 answers

C++ development on linux - where do I start?

I decided to leave my windows install behind and am now running Debian as my default OS. I have always coded in Windows and specifically with Visual Studio. I am currently trying to get used to compiling my code under linux. Although I still have a…
Daniel Sloof
  • 12,568
  • 14
  • 72
  • 106
43
votes
5 answers

Linker error LNK2038: mismatch detected in Release mode

I am trying to port a small app of mine from Win XP and VS 2005 to Win 7 and VS 2010. The app compiles and runs smoothly in Debug mode, however in Release mode I get the following error: pcrecpp.lib(pcrecpp.obj) : error LNK2038: mismatch detected…
Wartin
  • 1,965
  • 5
  • 25
  • 40
43
votes
2 answers

Compile a Standalone Static Executable

I'm trying to compile an executable (ELF file) that does not use a dynamic loader. I built a cross compiler that compiles mips from linux to be used on a simulator I made. I asserted the flag -static-libgcc on compilation of my hello.cpp file…
Dan Snyder
  • 1,483
  • 7
  • 20
  • 29
43
votes
1 answer

crt0.o and crt1.o -- What's the difference?

Recently I've been trying to debug some low-level work and I could not find the crt0.S for the compiler (avr-gcc) but I did find a crt1.S (and the same with the corresponding .o files). What is the difference between these two files? Is crt1…
Earlz
  • 62,085
  • 98
  • 303
  • 499