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
29
votes
8 answers

crti.o file missing

I'm building a project using a GNU tool chain and everything works fine until I get to linking it, where the linker complains that it is missing/can't find crti.o. This is not one of my object files, it seems to be related to libc but I can't…
Richard
  • 1,298
  • 6
  • 17
  • 27
29
votes
3 answers

Access symbols defined in the linker script by application

In my linker script file, I have defined two symbols define symbol _region_RAM_start__ = 0xC0000000; define symbol _region_RAM_end__ = 0xC00fffff; and then I have exported them as well as shown below export symbol…
ka05
  • 594
  • 1
  • 5
  • 12
29
votes
3 answers

How to declare an inline function in C99 multi-file project?

I want to define an inline function in a project, compiled with c99. How can I do it? When I declare the function in a header file and give the detail in a .c file, the definition isn't recognized by other files. When I put the explicit function in…
mousomer
  • 2,632
  • 2
  • 24
  • 25
29
votes
4 answers

Building Boost for static linking (MinGW)

I'm building Boost (I'm using System and FileSystem) for MinGW using bjam: bjam --toolset=gcc stage And it builds fine, but I want to be able to statically link to it (I have to have a single file for the final product) so I tried: bjam…
Adam
  • 25,966
  • 23
  • 76
  • 87
29
votes
3 answers

When importing a java library class from jar, is this considered static linking? or dynamic?

say I have jcifs-1.3.14.jar in my lib folder, and I have a class that is importing from the library and uses the classes like: import jcifs.smb.*; NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain, …
Jim Ford
  • 1,095
  • 1
  • 13
  • 21
29
votes
6 answers

questions about name mangling in C++

I am trying to learn and understand name mangling in C++. Here are some questions: (1) From devx When a global function is overloaded, the generated mangled name for each overloaded version is unique. Name mangling is also applied to variables.…
Tim
  • 1
  • 141
  • 372
  • 590
29
votes
2 answers

Actual default linker script and settings gcc uses

Where can I find the actual linker script and settings gcc uses? Things I've tried: For concreteness, let's consider a small program: empty.c int main(void) { return 0; } build it statically, and look at the result: $ gcc -static…
RabbitEars
  • 361
  • 1
  • 4
  • 6
29
votes
13 answers

linking problem: fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

Im trying to run sample app from wxFreeChart library. After compilation on linking there is an error: wxcode_msw28d_freechart.lib(wxfreechart_lib_xydataset.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type…
gruber
  • 28,739
  • 35
  • 124
  • 216
29
votes
4 answers

how do compilers assign memory addresses to variables?

I teach a course where students get to ask questions about programming (!): I got this question: Why does the machine choose were variables go in memory? Can we tell it where to store a variable? I don't really know what to say. Here's my first…
Dervin Thunk
  • 19,515
  • 28
  • 127
  • 217
29
votes
3 answers

Framework not found AudioUnit

Been banging my head agains the wall for awhile now. My Xcode project went a little haywire while refactoring, and refused to build. I've squashed all the other errors, except one last linktime error: Framework not found AudioUnit I have the…
alexbw
  • 2,028
  • 2
  • 21
  • 25
29
votes
3 answers

Why are (member) function pointers behaving so weirdly in Visual C++?

I've had a really bizarre problem that I've reduced to the following test case: #include #include #include struct Test { std::map m; Test() { this->m["test1"] =…
user541686
  • 205,094
  • 128
  • 528
  • 886
28
votes
3 answers

"LNK2022: metadata operation failed" driving me insane

I have a big solution with lots of projects, using VS2008 SP1, and at least once a day I encounter the LNK2022 error. If I do a full rebuild of the solution it builds fine, but this is not fun. It happens when a dependent DLL is changed…
demoncodemonkey
  • 11,730
  • 10
  • 61
  • 103
28
votes
7 answers

How can I create an executable .exe PE file manually?

All texts on how to create a compiler stop after explaining lexers and parsers. They don't explain how to create the machine code. I want to understand the end-to-end process. Currently what I understand is that, the Windows exe file formats are…
28
votes
4 answers

How to link a .DLL statically?

We have a (pure native C++) .DLL that is build by VS. As clients we have some native C++ applications and a .Net-Wrapper around this DLL written in C++/CLI. Finally there are some client applications for the .Net-Wrapper written in C#. My problem is…
mmmmmmmm
  • 15,269
  • 2
  • 30
  • 55
28
votes
5 answers

Are llvm-gcc and clang binary compatible with gcc? - particularly mingw gcc on Windows

If I build a static library with llvm-gcc, then link it with a program compiled using mingw gcc, will the result work? The same for other combinations of llvm-gcc, clang and normal gcc. I'm interested in how this works out on Linux (using normal…
user180247