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.

2795 questions
22
votes
5 answers

Linkage against libQt5Core

I installed Qt5.4 with the online installer (working on ubuntu 14). I'm trying to compile my c++ source and link against libQt5Core but ld throw an error: make g++ -Wall test.o Party.o Communication.o FileParser.o PeerConnection.o ServerModule.o…
Bush
  • 2,433
  • 5
  • 34
  • 57
22
votes
1 answer

g++ Optimization Flags: -fuse-linker-plugin vs -fwhole-program

I am reading: http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html It first suggests: In combination with -flto using this option (-fwhole-program) should not be used. Instead relying on a linker plugin should provide safer and more precise…
Hei
  • 1,844
  • 3
  • 21
  • 35
22
votes
2 answers

let's analyse "collect2: ld returned 1 exit status"?

I know this indicates a linker problem, mostly unresolved symbols. I know that to resolve that problem / to get rid of that errormessage, one would have to provide much more information. I know there is a lot of questions on resolving this problems…
lImbus
  • 1,578
  • 3
  • 14
  • 25
21
votes
1 answer

Does the order of -l and -L options in the GNU linker matter?

The -l option tells the linker to search the libraries in the standard dirs. And with -L, we can specify our own library directories for searching. Question: Does the sequence of order matters for the -L option too, like it does for the -l w.r.t the…
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
21
votes
2 answers

Incremental linking using gcc on linux. Is it possible?

The way my team's project is developed, we generate a Shared Object library for our application from all all of our .o object files. My task (hopefully it is specific enough but also general enough to be of use to others!) is to link in only the…
Raphael Raven
  • 213
  • 2
  • 5
21
votes
4 answers

Where are the symbols etext, edata and end defined?

This is a code from Linux man page: #include #include extern char etext, edata, end; int main() { printf("First address past:\n"); printf(" program text (etext) %10p\n", &etext); printf(" initialized…
atv
  • 1,950
  • 4
  • 21
  • 26
20
votes
1 answer

Why am I getting a gcc "undefined reference" error trying to create shared objects?

Why am I getting an "undefined reference" error using gcc? I am trying to create a shared object (.so) that exports one function, "external()". I then try to link against the .so but get "undefined reference 'external'". What am I doing wrong…
Warren
  • 1,903
  • 1
  • 21
  • 30
20
votes
1 answer

How to specify RPATH in a makefile?

I'm trying to specify rpath in my binary. My makefile looks like this- CC=gcc CFLAGS=-Wall LDFLAGS= -rpath='../libs/' main: main.c gcc -o main main.c clean: rm -f main main.o But when I query rpath using command readelf -a ./main |…
user837208
  • 2,487
  • 7
  • 37
  • 54
20
votes
3 answers

What is causing sprof to complain about "inconsistency detected by ld.so"?

I'm trying to use sprof to profile some software (ossim) where almost all the code is in a shared library. I've generated a profiling file, but when I run sprof, I get the following error: > sprof /home/eca7215/usr/lib/libossim.so.1…
Edward
  • 1,786
  • 1
  • 15
  • 33
20
votes
4 answers

How to link a gas assembly program that uses the C standard library with ld without using gcc?

As an exercise to learn more precisely how c programs work and what minimum level of content must exist for a program to be able to use libc, I've taken it upon myself to attempt to program primarily in x86 assembly using gas and ld. As a fun little…
Cyro
  • 203
  • 1
  • 2
  • 4
20
votes
1 answer

How do I increase the stack size when compiling with Clang on OS X?

Can I specify the stack size with clang++? I can't find any compiler options that would allow me to do so. I'm using OS X. Note: This question specifically refers to Clang, not the GCC compiler.
Rob Lachlan
  • 14,289
  • 5
  • 49
  • 99
20
votes
3 answers

Why Linux/gnu linker chose address 0x400000?

I'm experimenting with ELF executables and the gnu toolchain on Linux x86_64: I've linked and stripped (by hand) a "Hello World" test.s: .global _start .text _start: mov $1, %rax ... into a 267 byte ELF64…
Andrew Tomazos
  • 66,139
  • 40
  • 186
  • 319
18
votes
4 answers

Get the start and end address of text section in an executable

I need to get the start and end address of an executable's text section. How can I get it? I can get the starting address from the _init symbol or the _start symbol, but what about the ending address? Shall I consider the ending address of the text…
phoxis
  • 60,131
  • 14
  • 81
  • 117
18
votes
5 answers

collect2: fatal error: ld terminated with signal 9 [Killed]

I'm trying to build precimonious on Ubuntu 16.04.3 x64. I allocated 1GB memory for it. My file structure looks like ~ |--- llvm/ |--- precimonious/ where the llvm is on version 3.0 as mentioned at…
Old Panda
  • 1,466
  • 2
  • 15
  • 30
18
votes
2 answers

Why I cannot override search path of dynamic libraries with LD_LIBRARY_PATH?

Edit: I resolved this issue, the solution is below. I am building a code in a shared computing cluster dedicated for scientific computing, thus I can only control files in my home folder. Although I am using fftw as an example, I would like to…
Mikael Kuisma
  • 302
  • 1
  • 2
  • 9