Questions tagged [linker]

The linker is part of the toolchain for producing executables from source code written in compiled programming languages. It takes compiled object code in multiple files and produces a single, "linked", executable file from them.

Separately-compiled programming languages such as C and C++ rely on a linker to turn one or more object files and libraries into an executable. The linker resolves undefined symbol references in object files by linking them to symbol definitions in other object files and libraries. The linker also arranges variables and functions to assign them addresses in the final executable,

On Unix-like operating systems the linker is typically named ld and is often invoked automatically by the compiler as the last step in the compilation process.

Books about linkers:

13907 questions
27
votes
3 answers

static library, but I still need headers?

I have a bunch of projects that all could share a "common" static library of classes. What confuses me is if I make a static library out of these classes and link against it in my projects that I still need the headers of the classes in the static…
MLS
  • 615
  • 1
  • 8
  • 12
27
votes
3 answers

How do I find where a symbol is defined among static libraries

Suppose you work with a codebase comprising several tools and libraries and you want to port (or resurrect) some component within such codebase but any clue about where symbols lie within the various libs is either lost or will take ages to find out…
a1an
  • 3,526
  • 5
  • 37
  • 57
27
votes
3 answers

Linking a shared library with another shared lib in linux

I am trying to build a shared library. Let us say libabc.so. It uses another .so file , say lib123.so (a lib in /usr/local/lib). Now I am using my shared lib libabc.so in my application. Say my-app. I want to know how I should link these binaries? I…
A R
  • 2,697
  • 3
  • 21
  • 38
27
votes
3 answers

How to write a linker

I have written a compiler for C that outputs byte code. The reason for this was to be able to write applications for an embedded platform that runs on multiple platforms. I have the compiler and the assembler. I need to write a linker, and am…
27
votes
2 answers

How can I link with (or work around) two third-party static libraries that define the same symbols?

I can't be the only one to run into this. I have a C++ application that needs to link with one third-party and another static library set in an SDK. The SDK has, for some hideously frustrating reason, recompiled a subset of that same third-party…
rutgersmike
  • 1,183
  • 9
  • 18
27
votes
7 answers

Xcode: Conditional Build Settings based on architecture (Device (ARM) vs Simulator (i386))

I'm building an iPhone app that has to run on both the simulator and the device. However I'm using an externally compiled library that has one version for the simulator and one for the device (different CPU). How can I do it? I'm coming from Visual…
noamtm
  • 12,435
  • 15
  • 71
  • 107
26
votes
1 answer

Boost: How bjam constructs a library name?

I was looking in the jam files, how the name of library is constructed. Example: libboost_log-mgw46-mt-1_48.dll I would like to ignore the last part, how to pass linker the -o parameter with my constructed name. I have few versions and linking in a…
Sandro Grm
  • 261
  • 3
  • 4
26
votes
1 answer

PDB 'vc100.pdb' was not found with

I have downloaded the FreeImage source code and done a static build myself for X64 MT DLL. Everything works fine, except when I use link in the freeimage.lib file I get a lot of annoying linker warnings which I don't quite understand the cause…
ronag
  • 49,529
  • 25
  • 126
  • 221
26
votes
3 answers

libiconv not linking to iOS project

I'm trying to compile MailCore into an iOS app I'm making, and the linker keeps complaining that libiconv isn't linked in. At least that's what I think it's complaining about. This is what it spits out: Undefined symbols for architecture i386: …
sarahhodne
  • 9,796
  • 3
  • 39
  • 44
26
votes
4 answers

Apple Mach-O linker (id) warning : building for MacOSX, but linking against dylib built for iOS

Starting from some point in the past xCode 4 in complaining about linker problems: ld: warning: building for MacOSX, but linking against dylib built for iOS: …
Igor
  • 261
  • 3
  • 4
26
votes
4 answers

rpath=$ORIGIN not having desired effect?

I've got a binary "CeeloPartyServer" that needs to find libFoundation.so at runtime, on a FreeBSD machine. They're both in the same directory. I compile (on another platform, using a cross compiler) CeeloPartyServer using linker flag…
Nektarios
  • 10,173
  • 8
  • 63
  • 93
26
votes
6 answers

force visual studio to link all symbols in a lib file

Is there any way to force visual studio to link all symbols from a lib file into the dll as atm it is optimizing "unused" functions which are needed by the program using the dll at run time. I tried using the /OPT:NOREF and /OPT:NOICF but they dont…
Lodle
  • 31,277
  • 19
  • 64
  • 91
26
votes
5 answers

GCC -lm -lz -lrt options - what are they about?

I know that these are some common/basic libraries, but what do they mean exactly? For example, I know, that -lm is some math library, but is this the standard math library or what? -lz for compression? What compression? And I don't have any idea…
Kiril Kirov
  • 37,467
  • 22
  • 115
  • 187
26
votes
5 answers

/usr/bin/ld: cannot find

I created a .so file and put it in the location /opt/lib and added this path to LD_LIBRARY_PATH now after this when I try to compile my main program with the following command: g++ -Wall -I/home/alwin/Development/Calculator/ main.cpp -lcalc -o…
Alwin Doss
  • 962
  • 2
  • 16
  • 33
26
votes
1 answer

Xcode returns linker error "library not found for -lFirebaseAuth"

I wanted to test firebase initial app on Unity. I made a build from Unity in macOS and in Xcode project folder, I have runned the pod command successfully. pod install After this I opened Xcode project and I clicked to build button. Before this, I…
Ali Avcı
  • 1,281
  • 1
  • 11
  • 24