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

c++ linker , how to link the iostream file?

I have a file named main.cpp which includes iostream. I compiled main.cpp and it worked without errors, so my question is: I compiled main.cpp and I did not link iostream with main.cpp, so how could this be possible? Or did the compiler linked the…
AlexDan
  • 3,203
  • 7
  • 30
  • 46
5
votes
1 answer

missing symbols in valgrind stacktrace

I'm using valgrind to debug a binary which uses loadable libraries via dlopen. On debian stable the stacktrace does not contain symbols for calls inside the loadable lib. | | ->11.55% (114,688B) 0x769492C: ??? | | | ->11.55% (114,688B) 0x7697289:…
b0ti
  • 2,319
  • 1
  • 18
  • 18
5
votes
1 answer

C++ Ruby Extension with External Libraries

I started a little experiment today: I wrote a C++ class which depends on some other libraries (ALGLIB, Eigen, internal tools) and I wanted to create a Ruby wrapper for that class. I'm currently using Rice to do that. First I wrote a very simple C++…
alfa
  • 3,058
  • 3
  • 25
  • 36
5
votes
2 answers

Compiling previously preprocessed file changes output

I have a source file which I preprocess using the options -E and -P (using GCC 4.1.2 for a vxWorks-based embedded platform). All other options are the same as when I compile the file. These options are: -Wall -march=pentium -nostdinc -O0…
Björn Pollex
  • 75,346
  • 28
  • 201
  • 283
5
votes
1 answer

How does the order input files affect linkage and static initializaion in GCC?

Suppose I have the following files: lib/A.h #ifndef A_H #define A_H #include class A { public: static int add( int x ); static int size(); private: static std::vector
fdlm
  • 614
  • 1
  • 5
  • 14
5
votes
4 answers

What is -lnuma and what program uses it for compilation?

I am compiling a message passing program using openmpi with mpicxx on a Linux desktop. My makefile does the following: mpicxx -c readinp.cpp mpicxx -o exp_fit driver.cpp readinp.o at which point i get the following…
drjrm3
  • 4,474
  • 10
  • 53
  • 91
5
votes
1 answer

Linking failing for PCRE when using Android NDK stand-alone toolchain

People have been able to build PCRE (or a subset of) by copying the source files and creating appropriate Andriod.mk. I want to do similar, but using an Android stand-alone toolchain and just using their configure and make process. I have had…
corbin
  • 1,446
  • 2
  • 27
  • 40
5
votes
2 answers

How to link wsock32 library through g++?

I'm using minGW on windows, trying to compile a c++ program. I've used sockets in there, so I'm trying to link (not include... I've already included winsock.h) the wsock32 library. I know that the -L switch is for linking but none of the following…
dsynkd
  • 1,999
  • 4
  • 26
  • 40
5
votes
2 answers

Linking libCurl in QT gives a huge list of errors C++

I am trying to link libCurl in QT to a C++ program on Windows 7 x64, but when I try to link libcurldll.a, I get a huge list of errors. I have tried compiling a similar function with GCC g++ -LC:\MinGW\lib -lcurldll which compiles without errors. I…
user99545
  • 1,173
  • 3
  • 16
  • 32
5
votes
1 answer

A linking error related to 'gcc' and '-lm'

Well, I think my problem is a little bit interesting and I want to understand what's happening on my Ubuntu box. I compiled and linked the following useless piece of code with gcc -lm -o useless useless.c: /* File useless.c */ #include…
LucasBr
  • 461
  • 1
  • 7
  • 19
5
votes
1 answer

In GCC, how can I export all typeinfo symbols for a shared library without exporting all symbols?

Here is the problem: I have a shared library that is hiding symbols by default. Actually, it uses the -Xlinker --version-script= option to export some symbols in a specific file but hide all the rest. The issue is that if we try to catch…
Will Brode
  • 1,026
  • 2
  • 10
  • 27
5
votes
2 answers

Replacing a name of a function using define macros in cpp correctly

I'm using Eclipse + Qualcomm libraries (in cpp) + Android SDK on Ubuntu. My application runs fine. If I change some code in the qualcomm libraries, it compiles and works correctly. The problem is: I have changed the name of the project, and I have…
vgonisanz
  • 11,831
  • 13
  • 78
  • 130
5
votes
1 answer

Linker error when using an extern template

I have working code with a template. Similar to the stl::string I am mostly using my template with one parameter across multiple compilation units. To save time I am trying to use extern instantiation. However changing the lines as follows yields an…
ted
  • 4,791
  • 5
  • 38
  • 84
5
votes
2 answers

how can I link a shared object in C?

I made a simple program that uses a shared object, opening it with dlopen(). I also compiled and linked the shared object like below: gcc -o libmylib.so libmylib.c -shared -fPIC -Wall gcc -o program program.c -L. -lmylib -ldl -Wall When I tried to…
Alexandru N. Onea
  • 423
  • 2
  • 6
  • 18
5
votes
4 answers

Linking .Net Assemblies

This is all hypothetical, so please bear with me. Say I'm writing a tool in C# called Foo. The output is foo.exe. I've found some really great library that I like to use called Bar, which I can reference as bar.dll in my project. When I build my…
user6202
  • 63
  • 4
1 2 3
99
100