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
18
votes
4 answers

ld cannot find -l

I am having trouble installing pyipopt on ubuntu 12.04. During linking, I receive the error: /usr/bin/ld: cannot find -lcoinhsl Even though I know that this library is installed and the .so and .la files are available in…
mo ba
  • 195
  • 1
  • 2
  • 7
18
votes
1 answer

Why does the ld linker allow multiple class definitions with the same methods?

Consider this file, first.cpp, containing a class definition and use: #include struct Foo { Foo(){ std::cout << "Foo()" << std::endl; } ~Foo(){ std::cout << "~Foo()" << std::endl; } }; int main(){ Foo f; return 0; } and…
Rafał Rawicki
  • 22,324
  • 5
  • 59
  • 79
18
votes
2 answers

MacOS -- how to link a dynamic library with a relative path using gcc/ld

If you are trying to understand dynamic linking, this question is likely to be of interest. One of the answers to that question provides a wonderful example of creating and using a dynamic library. Based on it, I some simple files: main.c: extern…
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
17
votes
1 answer

-fsanitize not using gold linker in GCC-6.1

Update (30-Sept-2016) The Ubuntu build of gcc-6.2 ((Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901) no longer has this issue. I'm using the Ubuntu build of gcc-6.1[1] ((Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511), GNU binutils 2.24, and libstdc++…
Tim
  • 1,517
  • 1
  • 9
  • 15
17
votes
2 answers

Can I trick libc (GLIBC_2.13) into loading a symbol it doesn't have (from GLIBC_2.15)?

In my attempt to get "Steam for Linux" working on Debian, I've run into an issue. libcef (Chromium Embedded Framework) works fine with GLIBC_2.13 (which eglibc on Debian testing can provide), but requires one pesky little extra function from…
user824425
16
votes
5 answers

How would you list the available functions etc contained within a compiled library?

How do I determine whether a function exists within a library, or list out the functions in a compiled library?
Anthony
  • 1,306
  • 4
  • 13
  • 23
16
votes
2 answers

When i should use ld instead of gcc?

I want to know when i should use ld linker instead off gcc. I just wrote a simply hello world in c++, of course i include iostream library. If i want make a binary file with gcc i just use: g++ hello hello.cpp and i've got my binary file. Later i…
Ice
  • 1,783
  • 4
  • 26
  • 52
16
votes
1 answer

Requirements to use flto

If I want to compile my project with -flto is it enough to have built gcc with --enable-gold or do I also need to build gold and replace ld with it? And do I need any other flags? Ie I'm doing this gcc -flto one.c two.c
chew socks
  • 1,406
  • 2
  • 17
  • 37
16
votes
2 answers

ld cannot find udev

I'm trying to compile a program but it throws the following error: [cc] /usr/bin/ld: cannot find -ludev I checked other topics on SO but the responses were to install something while I seem to be having libudev installed. In /lib/x86_64-linux-gnu I…
user294034
  • 323
  • 1
  • 2
  • 9
16
votes
4 answers

ld warning: too many personality routines for compact unwind to encode

The linker for an iOS simulator target I have is reporting the following warning: ld: warning: too many personality routines for compact unwind to encode No line number is given, nor anything else that is actionable. Googling turned up some Apple…
Doug Richardson
  • 10,483
  • 6
  • 51
  • 77
15
votes
1 answer

Injecting sections into GNU ld script; script compatibility between versions of binutils.

I'm building something like in the question How to collect data from different .a files into one array? How to keep sections in .a files with ld script?, i.e. arrays composed during link-time out of elements from different object files. In my case,…
epij
  • 568
  • 3
  • 14
15
votes
2 answers

How to force linkage to older libc `fcntl` instead of `fcntl64`?

It seems GLIBC 2.28 (released August 2018) made a fairly aggressive change to fcntl. The definition was changed in to no longer be an external function, but a #define to fcntl64. The upshot is that if you compile your code on a system…
15
votes
2 answers

unable to compile: unrecognized relocation 0x2a in section text

I have received an error message when compiled "make" $ make g++ -fopenmp -o lang.test main.o -I../../../include/Lheader -I../../../include -L../../../lib/ -llmi -lblas -lboost_regex -lpthread -lleveldb /usr/bin/ld:…
Gi Yeon Shin
  • 357
  • 2
  • 7
  • 19
15
votes
1 answer

Why do I get "ld: warning: direct access in _main to global weak symbol" in this simple code?

It's very strange behavior in my Clang compiler. I use Xcode (OS X), all is up-to-date. Why am I getting this warning in that simple code? If I remove those two lines the warning hides. ld: warning: direct access in _main to global weak symbol …
JavaRunner
  • 2,455
  • 5
  • 38
  • 52
15
votes
4 answers

glui /usr/bin/ld: cannot find -lXmu

I have downloaded the latest GLUI source code and now I am trying to compile it. When I do so, I get the following error: g++ -O0 -Wall -pedantic -I./ -I./include -I/usr/X11R6/include -o bin/example1 example/example1.cpp -L./lib -lglui…
Myx
  • 1,792
  • 5
  • 23
  • 37