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
6
votes
2 answers

How do I activate Dead Code Stripping when building for the iOS Simulator in Xcode?

I am using Xcode to build a project that links precompiled object files. These object files contain some unresolved symbols that are dead-code. When Xcode builds for the iOS Device, it strips them when linking and everything works smoothly. When…
Holger
  • 1,648
  • 1
  • 16
  • 26
6
votes
2 answers

Importing inline functions in MinGW

I'm using a shared library that defines inline functions in its header. Here is a reduced test case, as seen by the compilation unit linking to the library (for the version seen by the library, just replace dllimport by dllexport). class…
Norswap
  • 11,740
  • 12
  • 47
  • 60
6
votes
3 answers

Unresolved External Symbol

Possible Duplicate: What is an undefined reference/unresolved external symbol error and how do I fix it? I am working on wrapping a large number of .h and .lib files from native C++ to Managed C++ for eventual use as a referenced .dll in C#. I…
TomO
  • 458
  • 2
  • 9
  • 20
6
votes
1 answer

"ld: library not found for -lXYZ" means what? What are the different possibilites?

What are the different possibilities when this error can occur? What are the things one should look out for, in order to get rid of this? What if XYZ is an static library directly added to project?
Vaibhav Tekam
  • 2,344
  • 3
  • 18
  • 27
6
votes
0 answers

g++ shared library not found same directory with -L

I just cant see what Im doing wrong here: Q. Why is my library not being found by g++ when compiling the program with a shared object? Im trying to include a shared library to my c++ program: g++ -fpic -c sha.cpp g++ -shared -o libsha.so sha.o g++…
user1453495
  • 61
  • 1
  • 2
6
votes
3 answers

Can unused member functions be reported by the linker? (C++)(gcc)

std::string has over 30 member functions that can be called on a string object. What if I only use a few of them? I assume the unused member functions will not take up space in the executable code section. I'm curious to know whether or not it's…
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
6
votes
3 answers

crt1.o no such file c++ compilation error on linux x64

I'm making my first steps on the linux platform. I've installed Centos x64. I'm attempting to build a small program with a couple of functions and a couple of unit tests. I'm using Netbeans 7.1.2 as the development environment. Here is the…
fishfood
  • 4,092
  • 4
  • 28
  • 35
6
votes
1 answer

Using static libraby in MFC

I try to use a static library in my MFC project but I get the following linker error: 1>------ Build started: Project: Csetkliens, Configuration: Debug Win32 ------ 1>Build started 2012.05.20. 16:12:49. 1>InitializeBuildStatus: 1> Touching…
Forro Istvan
  • 307
  • 2
  • 6
  • 11
6
votes
3 answers

how to avoid "already defined error" in C++

I am gettings these type of errors in a MFC VS6 project while linking the application: msvcrt.lib(MSVCRT.dll) : error LNK2005: _atoi already defined in LIBC.lib(atox.obj) I know what it means (a function exists in 2 different libraries); to solve…
Mantichora
  • 79
  • 1
  • 1
  • 6
6
votes
2 answers

Link compatibility of enums and enum classes

Suppose there is a C++11 API that uses enum classes: // api.hpp enum class E {A, B, C}; void f(E); ... // api.cpp void f(E e) { if (e == E::A) ... } Now suppose I would like to use this API, but I don't have a C++11 compiler. So…
HighCommander4
  • 50,428
  • 24
  • 122
  • 194
6
votes
3 answers

Why Am I Getting Link Errors When Calling Function in Math.h?

When attempting to call functions in math.h, I'm getting link errors like the following undefined reference to sqrt But I'm doing a #include I'm using gcc and compiling as follows: gcc -Wall -D_GNU_SOURCE blah.c -o blah Why can't the…
FreeMemory
  • 8,444
  • 7
  • 37
  • 49
6
votes
1 answer

Linking boost libraries

I have downloaded the boost library (version 1.46.1), but I don't know how to link it through xcode.I found an old question says to put the -lfftw3 flag, so I've put it. I also added the path: /home/Documents/C++/boost_1_46_1 (it's the directory…
Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187
6
votes
2 answers

Undefined reference to MySQL libraries using g++

I am getting undefined reference to 'mysql_suchandsuch@#' messages when trying to link my program with the MySQL libraries supplied with the 5.5 server. When MySQL was installed, I used the default path, which for me on Windows is C:\Program…
Gaffi
  • 4,307
  • 8
  • 43
  • 73
6
votes
2 answers

Does appending arbitrary data to an ELF file violate the ELF spec?

I would like to add some information to an ELF file, but it ideally needs to be done in a way that a program can easily read this information without understanding ELF or using tools outside a normal standard language library. I was thinking of…
Denver Gingerich
  • 1,587
  • 2
  • 12
  • 6
5
votes
2 answers

How to tell qmake to use static libraries if both dynamic and static versions exist?

I have both static and dynamic versions of Boost installed in /usr/local/lib, i.e. both libboost_system.dylib and libboost_system.a exist. In my qmake project file I've added the Boost libraries to the linker like so: LIBS += -lboost_system Can I…
Jake Petroules
  • 23,472
  • 35
  • 144
  • 225