Questions tagged [ld]

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.

2460 questions
270
votes
4 answers

I don't understand -Wl,-rpath -Wl,

For convenience I added the relevant manpages below. My (mis)understanding first: If I need to separate options with ,, that means that the second -Wl is not another option because it comes before , which means it is an argument to the -rpath…
Blub
  • 11,602
  • 14
  • 63
  • 96
256
votes
1 answer

What's the difference between .so, .la and .a library files?

I know an .so file is a kind of dynamic library (lots of threads can share such libraries so there is no need to have more than one copy of it in memory). But what is the difference between .a and .la? Are these all static libraries? If dynamic libs…
hugemeow
  • 7,177
  • 13
  • 43
  • 59
174
votes
3 answers

LD_LIBRARY_PATH vs LIBRARY_PATH

I'm building a simple C++ program and I want to temporarily substitute a system supplied shared library with a more recent version of it, for development and testing. I tried setting the LD_LIBRARY_PATH variable but the linker (ld) failed…
Georgios Politis
  • 2,280
  • 2
  • 16
  • 10
167
votes
6 answers

How to print the ld(linker) search path

What is the way to print the search paths that in looked by ld in the order it searches.
Talespin_Kit
  • 17,730
  • 25
  • 86
  • 117
126
votes
17 answers

Compiling problems: cannot find crt1.o

I have a virtual Debian system which I use to develop. Today I wanted to try llvm/clang. After installing clang I can't compile my old c-projects (with gcc). This is the error: ... /usr/bin/ld: cannot find crt1.o: No such file or…
Stefan Keller
  • 1,263
  • 2
  • 9
  • 5
123
votes
11 answers

How to remove unused C/C++ symbols with GCC and ld?

I need to optimize the size of my executable severely (ARM development) and I noticed that in my current build scheme (gcc + ld) unused symbols are not getting stripped. The usage of the arm-strip --strip-unneeded for the resulting executables /…
Yippie-Ki-Yay
  • 20,062
  • 23
  • 85
  • 143
98
votes
1 answer

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

gcc and ld provide many ways to specify a search path for libraries—among them the -rpath and -L flags. The manpages reveal no differences between these two flags, effectively saying each flag adds a library to the library search path. Yet it seems…
Craig M. Brandenburg
  • 2,624
  • 2
  • 22
  • 33
90
votes
2 answers

combine two GCC compiled .o object files into a third .o file

How does one combine two GCC compiled .o object files into a third .o file? $ gcc -c a.c -o a.o $ gcc -c b.c -o b.o $ ??? a.o b.o -o c.o $ gcc c.o other.o -o executable If you have access to the source files the -combine GCC flag will merge the…
Lucian Adrian Grijincu
  • 2,242
  • 2
  • 17
  • 17
84
votes
1 answer

What are the --start-group and --end-group command line options?

What is the purpose of those command line options? Please help to decipher the meaning of the following command line: -Wl,--start-group -lmy_lib -lyour_lib -lhis_lib -Wl,--end-group -ltheir_lib Apparently it has something to do with linking, but…
pic11
  • 12,658
  • 17
  • 74
  • 108
73
votes
3 answers

Why does the order of '-l' option in gcc matter?

I am trying to compile a program which uses udis86 library. Actually I am using an example program given in the user-manual of the library. But while compiling, it gives error. The errors I get are: example.c:(.text+0x7): undefined reference to…
user1129237
68
votes
5 answers

How to set the LDFLAGS in CMakeLists.txt?

I set the CFLAGS in CMake by CMAKE_C_FLAGS. Is something like this to set LDFLAGS?
paykoob
  • 1,457
  • 2
  • 14
  • 31
65
votes
3 answers

ld: library not found for -lcrt0.o on OSX 10.6 with gcc/clang -static flag

When I try to build the following program: #include int main(void) { printf("hello world\n"); return 0; } On OS X 10.6.4, with the following flags: gcc -static -o blah blah.c It returns this: ld: library not found for…
browneye
  • 651
  • 1
  • 5
  • 3
64
votes
3 answers

What is the difference between -I and -L in makefile?

What is the usage of the -I and -L flags in a makefile?
MainID
  • 25,722
  • 19
  • 53
  • 70
59
votes
0 answers

How to get the size of an input section (to place it at the end of memory)

I have the following linker script: .data & .bss are placed into ram, then a .heap section fills the remaining memory. Now I want to add a .noinit section that always gets placed at the end of the memory. That is so it gets ignored by bootloaders…
user1273684
  • 1,169
  • 11
  • 22
56
votes
13 answers

linker error while linking boost log tutorial (undefined references)

I have installed boost on Fedora 20 via yum and am trying some simple examples. However I have trouble to compile the first example from the logging tutorial. Compiling with g++ -c boosttest.cc works fine, but I get lot's of errors when I try to…
Michael Große
  • 1,457
  • 1
  • 13
  • 18
1
2 3
99 100