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
1
vote
1 answer
NASM call label doesn't get called
I'm doing some assembly coding using NASM on Linux but I've run into a problem.
global _start
section .text
testFunctionName:
mov rdi, 12
ret
_start:
call testFunctionName
mov rax, 1
mov rbx, 0
int 0x80
then assembled…

Jeremy Moyes
- 139
- 1
- 1
- 7
1
vote
0 answers
Using ld to link a file makes it too big for a boot loader, works in nasm though :(
I'm trying to make a simple bootloader, but running into issues with ld (I think).
When I compile my assembly file (below) with nasm -f bin, it works and I get a nice 512 byte file. For that one I include org 0x7c00 at the top and everything works…
user9425138
1
vote
0 answers
how is thread local storage via gcc __thread keyword implemented in x86_64?
I'm digging around in libc and found an interesting asm sequence that I try to understand. glibc-2.27/malloc/malloc.c has:
static __thread tcache_perthread_struct *tcache = NULL;
...
# define MAYBE_INIT_TCACHE() \ …

Konrad Eisele
- 3,088
- 20
- 35
1
vote
1 answer
Linking an openGL library fails because it can't open libgl.so ... but it's right there
I've been getting the following error when I try to make a c++ project with openGL that's been really elusive to me. When i run the make file, I get the following:
g++ -c init.cpp
g++ -o executable console.o init.o -lglut…

Duro Dur
- 13
- 2
1
vote
2 answers
ld skips shared library
I am trying to deploy a Qt application by providing the Qt libraries as shared libraries in a directory and pointing ld to them using LD_LIBRARY_PATH. This works for all Qt libraries such as libQt5Network or libQt5Gui, but not for libQt5Core which…

DJohnson
- 23
- 4
1
vote
0 answers
ldconfig Does not Include Dynamic Library With non Standard Naming?
I have /foo/lib64/bar.so
I could link it correctly but when I start my application, it complains:
myapps: error while loading shared libraries: bar.so: cannot open shared object file: No such file or directory
I created /etc/ld.so.conf.d/bar.conf…

HCSF
- 2,387
- 1
- 14
- 40
1
vote
1 answer
Final step in GCC compiling (ld) issue
I'm trying to write a makefile that goes through compilation step by step, the issue is on the fourth step, linking.
The program consists of multiple files, starting with main.c:
#include "file1.h"
#include "file2.h"
int main() {
printout1("Print…

Spookie Ougi
- 45
- 5
1
vote
0 answers
C++: including header file results in "symbol(s) not found for architecture", while including .cpp file works
I'm compiling a project that has several header files, one of them is a general "utils" file with general-purpose functions.
When I include the header file for this utils file, compilation fails (see error below), but when I include the actual .cpp…

Nur L
- 791
- 7
- 15
1
vote
0 answers
Set Location Counter to a new value in linker script
I'm confused about the location counter, especially when setting it to
a new value in the output section.
I write a simple program and a linker script to make my question more
clear. The code is as follows:
test.s
section .text
.globl…

haolee
- 892
- 9
- 19
1
vote
1 answer
How to implement custom output section in GNU LD?
I'm trying to figure out how to define a custom output section in my application's LD file. So far, this is what I've come up with...
MEMORY
{
...
m_my_custom_section (RW) : ORIGIN = 0x00002400, LENGTH = 0x00000400
...
}
SECTIONS
{
...
…

Jim Fell
- 13,750
- 36
- 127
- 202
1
vote
1 answer
Unable to run gcc on mac
I am trying to compile simple C code on my system. I am running gcc version (4.9.2) on macOS 10.11.6.
ld: library not found for -lgcc
collect2: error: ld returned 1 exit status
I am unable to fix this issue. This problem is not letting me install…

learner
- 288
- 2
- 16
1
vote
1 answer
Why ping does work from user, but does not work as root? Why root cannot load existing libraries, while user can?
I discovered, that ping works when run as user, but does not work when beeing root. The problem is, that when beeing root, LD does not load /lib64/libnss_dns.so.2 library, it gets EACCESS error.
When i run ping from root:
root# ping -c1…

KamilCuk
- 120,984
- 8
- 59
- 111
1
vote
1 answer
how to limit undefined symbol errors in ld?
Often, when a library is missing, the link step will show a ton of Undefined symbols errors, eg:
Undefined symbols for architecture x86_64:
"std::__1::error_code::message() const", referenced from:
llvm::errorToErrorCode(llvm::Error) in…

timotheecour
- 3,104
- 3
- 26
- 29
1
vote
1 answer
How to put functions from one object file to one special section and memory region for GCC linker?
How to put functions from one object file to one special section and memory region for GCC linker?
I am building one standalone application for Xilinx MPSoC A53 processor. GNU ld from Linaro 2.27 is used. Xilinx software is Xilinx SDK 2017.4. I plan…

Hank Fu
- 43
- 5
1
vote
2 answers
Embedding Lua in C++: linkage problems (liblua5.1.a)
I am embedding Lua in a C++ application and I am getting the following linkage errors:
g++ -o dist/Debug/GNU-Linux-x86/testluaembed build/Debug/GNU-Linux-x86/src/main.o build/Debug/GNU-Linux-x86/src/LuaBinding.o…

oompahloompah
- 9,087
- 19
- 62
- 90