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
43
votes
3 answers

How does C++ linking work in practice?

How does C++ linking work in practice? What I am looking for is a detailed explanation about how the linking happens, and not what commands do the linking. There's already a similar question about compilation which doesn't go into too much detail:…
Klaufir
  • 751
  • 1
  • 7
  • 10
43
votes
2 answers

Xcode : warning: directory not found for option

Ld /Users/pwang/Library/Developer/Xcode/DerivedData/socketiohldwxnslzhlnjtgihgewdwavpjpb/Build/Products/Debug-iphoneos/socketio.app/socketio normal armv7 cd /Users/pwang/Desktop/saturngod-Socket.io-with-iOS-be51414 setenv IPHONEOS_DEPLOYMENT_TARGET…
pengwang
  • 19,536
  • 34
  • 119
  • 168
42
votes
1 answer

Is there a difference between the "-Wl,option" and "-Xlinker option" syntax for GCC?

I have been looking through some configuration files and I've seen both being used (albeit on different architectures). If you're using GCC on a Linux box, is there a difference between the two syntaxes for passing options to the linker? Reading the…
bpw1621
  • 2,962
  • 2
  • 32
  • 35
42
votes
1 answer

nm symbol output t vs T in a shared so library

I have added a new function (fuse_lowlevel_notify_inval_directory) in user space fuse library. The compilation and creation of libfuse.so is finished without error. But when my application tries to use this new function, the linker is throwing…
ashish
  • 813
  • 3
  • 10
  • 18
42
votes
1 answer

Using Cython To Link Python To A Shared Library

I am trying to integrate a third party library written in C with my python application using Cython. I have all of the python code written for a test. I am having trouble finding an example for setting this up. I have a pyd/pyx file I created…
josephmisiti
  • 9,862
  • 11
  • 56
  • 72
42
votes
5 answers

Using a static library in Qt Creator

I'm having a hell of a time finding documentation which clearly explains how to use a static library in Qt Creator. I've created and compiled my static library using Qt Creator (New=>Projects\C++ Library=>Set type to "Statically Linked Library"). It…
Dan O
  • 4,323
  • 5
  • 29
  • 44
41
votes
1 answer

cmake find_package specify path

I have 2 versions of OpenCV installed on my machine. One is in /usr/local/opencv3.1. I presume the install location of the other one (version 3.4) is /usr/local. Anyway, find_package(OpenCV 3.0 REQUIRED) sets OpenCV_DIR:PATH=/usr/local/share/OpenCV.…
Gerry
  • 1,938
  • 3
  • 18
  • 25
41
votes
1 answer

what is the difference between ranlib, ar, and ld for making libraries

To make libraries in c++/unix from *.o files, I have noticed two different ways in my project (legacy code): ar qc libgraphics.a *.o ranlib libgraphics.a and ld -r -o libgraphics.a *.o What is the difference between the two approaches, and which…
R71
  • 4,283
  • 7
  • 32
  • 60
41
votes
2 answers

Compile with older libc (version `GLIBC_2.14' not found)

I have to compile a program on a current ubuntu (12.04). This program should then run on a cluster using CentOS with an older Kernel (2.6.18). I cannot compile on the cluster directly, unfortunately. If I just compile and copy the program without…
Flogo
  • 1,673
  • 4
  • 20
  • 33
40
votes
7 answers

Making small haskell executables?

Are there any good ways to make small haskell executables? With ghc6 a simple hello world program seems to come to about 370kB (523kB before strip). Hello world in C is about 4kB (9kB before strip).
Anthony Towns
  • 2,864
  • 1
  • 19
  • 23
40
votes
4 answers

How to use OpenSSL with Visual Studio

I am trying to port my console application written in C to Visual Studio 2010. On Linux/Mac, the application runs perfectly, including OpenSSL support. Can anyone provide help using/linking the OpenSSL libs in a Visual Studio project? Thanks!
user435739
39
votes
3 answers

Resolving circular dependencies by linking the same library twice?

We have a code base broken up into static libraries. Unfortunately, the libraries have circular dependencies; e.g., libfoo.a depends on libbar.a and vice-versa. I know the "correct" way to handle this is to use the linker's --start-group and…
Nemo
  • 70,042
  • 10
  • 116
  • 153
39
votes
4 answers

library is linked but reference is undefined

I'm trying to compile an openCL program on Ubuntu with an NVIDIA card that worked once before, #include #include #include using namespace std; int main() { cl_platform_id platform; cl_device_id device; …
user615457
  • 817
  • 1
  • 7
  • 13
39
votes
3 answers

What's the difference between gtest.lib and gtest_main.lib?

Google's C++ Test Framework has two output libraries: one is gtest.lib and the other one is gtest_main.lib. According to Nik Reiman's answer on how to setup gtest with Visual Studio, we should link to gtest_main.lib but I'm linking to gtest.lib and…
Kiril
  • 39,672
  • 31
  • 167
  • 226
39
votes
3 answers

Is a statically linked executable faster than a dynamically linked executable?

Since the dynamically linked libraries have to be resolved at run-time, are statically linked executables faster than dynamically linked executables?
Hungary Coder
  • 409
  • 1
  • 4
  • 4