The ld (linker or loader) program combines object files, archive files and (references from) shared libraries, relocates their data and addresses together with symbol references. Linking is usually the final step of compiling a program.
Questions tagged [ld]
2795 questions
31
votes
4 answers
Include binary file with GNU ld linker script
I have a working linker script. I want to add another data section whose contents is pulled directly from a file (ld shouldn't parse it and extract the sections and so on). How can I do that?
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
SECTIONS
{
…

Pandemonium
- 421
- 1
- 4
- 7
31
votes
2 answers
No realize class procedure defined
I just want to share how I found the solution to the error
No realize class procedure defined
when running a X/Motif C application. I am posting this because I only found one reference to this problem while searching online, and it contained no…

Miguel Rentes
- 994
- 1
- 10
- 27
28
votes
3 answers
Is the lld linker a drop-in replacement for ld and gold?
The linker from the LLVM project lld is currently developed with new features added week by week. Its developers promise that lld is faster than ld. How does it compete compared to gold?
Is lld a drop-in replacement for ld? With gold there are some…

usr1234567
- 21,601
- 16
- 108
- 128
27
votes
2 answers
How to set RPATH and RUNPATH with GCC/LD?
I recently encountered this problem after an upgrade of the system: using the GCC -Wl,-rpath= option works differently than before.
I used it to set the search paths to some shared libraries that were built in a sub-module of my project. At the time…

Machta
- 1,656
- 2
- 16
- 28
27
votes
3 answers
LD_PRELOAD does not work as expected
Consider the following library which can be preloaded before any program execution:
// g++ -std=c++11 -shared -fPIC preload.cpp -o preload.so
// LD_PRELOAD=./preload.so
#include
struct Goodbye {
Goodbye() {std::cout <<…

Martin
- 9,089
- 11
- 52
- 87
27
votes
4 answers
SDKROOT path for latest SDK
I am using Xcode to build an old code and specify SDKROOT=/Developer/SDKs/MacOSX"${HOST_VERSION}".sdk/
I want to specify SDKROOT for latest SDK that comes pre-installed (?) on the system. e.g. I am on 10.8 already and I want to specify SDKROOT with…

JamesWebbTelescopeAlien
- 3,547
- 2
- 30
- 51
26
votes
3 answers
Create a static Haskell Linux executable
It's not often two things I love so much come together to cause me so much annoyance (besides my kids). I've written a Haskell program at work that uses libraries like text, xml-enumerator, attoparsec-text, etc. I have it working properly on my…

Michael Snoyman
- 31,100
- 3
- 48
- 77
26
votes
1 answer
Force GNU linker to generate 32 bit ELF executables
Hi I am currently generating x86 assembly for a compiler that I am writing and am having some trouble linking the file on my 64-bit VM (the assembly code is 32 bit).
I was able to assemble the object file fine with this command:
as --32 mult.S -o…

Hunter McMillen
- 59,865
- 24
- 119
- 170
26
votes
3 answers
How to build a C program using a custom version of glibc and static linking?
I have built glibc 2.14 and installed it in directory ~/GLIBC/glibc_install. Now I want to build and run programs using this C library instead of my system's default C library.
To be sure that I was using my custom glibc, I added a call to puts…

Amittai Aviram
- 2,270
- 3
- 25
- 32
25
votes
4 answers
nasm - Can't link object file with ld on macOS Mojave
I'm trying to assemble a simple Hello World, which worked fine in the previous macOS version:
global start
section .text
start: mov rax, 0x02000004
mov rdi, 1
mov rsi, msg
mov rdx, 13
…

Verloren
- 859
- 1
- 8
- 18
24
votes
3 answers
Is g++ both a c++ compiler and a linker?
I was looking at the output from my build in Eclipse. I'm cross compiling for a ColdFire processor. The compilation line looks like this:
m68k-elf-g++ -O2 -falign-functions=4 -IC:\nburn\include -IC:\nburn\MOD52...
followed by more include file,…

Tod
- 8,192
- 5
- 52
- 93
23
votes
5 answers
ALIGN in Linker Scripts
What does the ALIGN keyword do in linker scripts? I read many tutorials about linker scripts but I cant understand what really ALIGN do. Can any one explain it simply. Thanks!

Jayanga Kaushalya
- 2,674
- 5
- 38
- 58
23
votes
8 answers
Linking a C program directly with ld fails with undefined reference to `__libc_csu_fini`
I'm trying to compile a C program under Linux. However, out of curiosity, I'm trying to execute some steps by hand: I use:
the gcc frontend to produce assembler code
then run the GNU assembler to get an object file
and then link it with the C…
user500944
23
votes
7 answers
load warning: cannot find entry symbol _start
I'm learning assembly programming. Below is the simple program that prints 'Hello, World!'. While the program runs perfectly, I'm getting the warning message while loading
ld: warning: cannot find entry symbol _start; defaulting to…

Atinesh
- 1,790
- 9
- 36
- 57
23
votes
2 answers
Compile and add an object file from a binary with CMake
I am writing an Excel file builder in C++.
I have everything I need working, but I still rely on an external empty .xlsx file which I unzip, iterate through, and add data too as needed to create the final file.
I want to remove this dependency by…

Tom Macdonald
- 6,433
- 7
- 39
- 59