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.

linker
Filter by
Sorted by
Tagged with
725 votes
18 answers
511k views

Embedding DLLs in a compiled executable

Is it possible to embed a pre-existing DLL into a compiled C# executable (so that you only have one file to distribute)? If it is possible, how would one go about doing it? Normally, I'm cool with ...
Merus's user avatar
  • 8,916
594 votes
11 answers
255k views

Why does the order in which libraries are linked sometimes cause errors in GCC?

Why does the order in which libraries are linked sometimes cause errors in GCC?
Landon's user avatar
  • 15.5k
521 votes
5 answers
296k views

How does the compilation/linking process work?

How does the compilation and linking process work? (Note: This is meant to be an entry to Stack Overflow's C++ FAQ. If you want to critique the idea of providing an FAQ in this form, then the posting ...
377 votes
5 answers
240k views

Difference between shared objects (.so), static libraries (.a), and DLL's (.so)?

I have been involved in some debate with respect to libraries in Linux, and would like to confirm some things. It is to my understanding (please correct me if I am wrong and I will edit my post later),...
Cloud's user avatar
  • 19k
300 votes
5 answers
120k views

What do 'statically linked' and 'dynamically linked' mean?

I often hear the terms 'statically linked' and 'dynamically linked', often in reference to code written in C, C++ or C#. What are they, what exactly are they talking about, and what are they linking?
UnkwnTech's user avatar
  • 89.3k
290 votes
6 answers
234k views

Resolving LNK4098: defaultlib 'MSVCRT' conflicts with

This warning: LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library is a fairly common warning in Visual Studio. I'd like to understand the exact ...
shoosh's user avatar
  • 77.7k
281 votes
18 answers
266k views

g++ undefined reference to typeinfo

I just ran across the following error: (.gnu.linkonce.[stuff]): undefined reference to [method] [object file]:(.gnu.linkonce.[stuff]): undefined reference to `typeinfo for [classname]' Why might one ...
cdleary's user avatar
  • 70.5k
274 votes
16 answers
659k views

libpthread.so.0: error adding symbols: DSO missing from command line

When I'm compiling openvswitch-1.5.0, I've encountered the following compile error: gcc -Wstrict-prototypes -Wall -Wno-sign-compare -Wpointer-arith -Wdeclaration-after-statement -Wformat-...
jaeyong's user avatar
  • 9,041
211 votes
11 answers
199k views

"/usr/bin/ld: cannot find -lz"

I am trying to compile Android source code under Ubuntu 10.04. I get an error saying, /usr/bin/ld: cannot find -lz Can you please tell me how can I fix it? What does cannot find -lz mean? Here's ...
michael's user avatar
  • 108k
208 votes
6 answers
238k views

How to print the ld(linker) search path

What is the way to print the search paths that in looked by ld in the order it searches.
Talespin_Kit's user avatar
  • 21.3k
202 votes
5 answers
182k views

What's an object file in C?

I am reading about libraries in C but I have not yet found an explanation on what an object file is. What's the real difference between any other compiled file and an object file? I would be glad if ...
Pithikos's user avatar
  • 19.5k
199 votes
5 answers
89k views

What do linkers do?

I've always wondered. I know that compilers convert the code you write into binaries but what do linkers do? They've always been a mystery to me. I roughly understand what 'linking' is. It is when ...
Kristina's user avatar
  • 16.1k
199 votes
7 answers
204k views

How can I link to a specific glibc version?

When I compile something on my Ubuntu Lucid 10.04 PC it gets linked against glibc. Lucid uses 2.11 of glibc. When I run this binary on another PC with an older glibc, the command fails saying there's ...
falstaff's user avatar
  • 3,533
193 votes
2 answers
315k views

Telling gcc directly to link a library statically

It feels strange to me to use -Wl,-Bstatic in order to tell gcc which libraries I want to link with statically. After all I'm telling gcc directly all other information about linking with libraries (-...
Elazar Leibovich's user avatar
190 votes
3 answers
131k views

What happens to global and static variables in a shared library when it is dynamically linked?

I'm trying to understand what happens when modules with globals and static variables are dynamically linked to an application. By modules, I mean each project in a solution (I work a lot with visual ...
Raja's user avatar
  • 2,986
183 votes
9 answers
742k views

ld cannot find an existing library

I am attempting to link an application with g++ on this Debian lenny system. ld is complaining it cannot find specified libraries. The specific example here is ImageMagick, but I am having similar ...
maxpenguin's user avatar
  • 5,099
179 votes
24 answers
273k views

error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj

I have read a lot of solutions to my problem but none helped. I tried clean, rebuild. Reinstalled visual 2010 and change from professional to ultimate. But still I dont know why I have this error. My ...
Qbunia's user avatar
  • 1,863
176 votes
6 answers
144k views

Linking static libraries to other static libraries

I have a small piece of code that depends on many static libraries (a_1-a_n). I'd like to package up that code in a static library and make it available to other people. My static library, lets call ...
Jason Sundram's user avatar
173 votes
5 answers
340k views

Why am I getting "undefined reference to sqrt" error even though I include math.h header? [duplicate]

I'm very new to C and I have this code: #include <stdio.h> #include <math.h> int main(void) { double x = 0.5; double result = sqrt(x); printf("The square root of %lf is %lf\n", x, ...
Ant's's user avatar
  • 13.7k
163 votes
6 answers
123k views

How do I determine the target architecture of static library (.a) on Mac OS X?

I'm interested in verifying if a given iPhone static library has been built for ARM or Intel. It's more curiosity than anything. Is there some kind of Mac OS X or BSD specific tool to do this? This ...
Justicle's user avatar
  • 15k
162 votes
6 answers
55k views

Objective-C categories in static library

Can you guide me how to properly link static library to iPhone project. I use static library project added to app project as direct dependency (target -> general -> direct dependencies) and all works ...
Vladimir's user avatar
  • 7,731
159 votes
10 answers
116k views

Is it feasible to compile Python to machine code? [closed]

How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python ...
Andy Balaam's user avatar
  • 6,561
158 votes
3 answers
33k views

Is it safe to link C++17, C++14, and C++11 objects

Suppose I have three compiled objects, all produced by the same compiler/version: A was compiled with the C++11 standard B was compiled with the C++14 standard C was compiled with the C++17 standard ...
ricab's user avatar
  • 2,722
139 votes
2 answers
143k views

What is the -fPIE option for position-independent executables in gcc and ld?

How will it change the code, e.g. function calls?
osgx's user avatar
  • 91.9k
139 votes
2 answers
18k views

Small Haskell program compiled with GHC into huge binary

Even trivially small Haskell programs turn into gigantic executables. I've written a small program, that was compiled (with GHC) to the binary with the size extending 7 MB! What can cause even a ...
user avatar
139 votes
9 answers
118k views

Visual C++: How to disable specific linker warnings?

I'm using a library from CGAL which during the linking stage of my code compilation produces a lot of linking warnings of this form: warning LNK4099: PDB 'vc80.pdb' was not found with 'gmp-vc80-mt-...
Ashwin Nanjappa's user avatar
138 votes
4 answers
106k views

Can I change 'rpath' in an already compiled binary?

I have an old executable that's scheduled for the scrap heap, but it's not there yet. It relies on some libs that have been removed from my environment, but I have some stub libs someplace where it ...
Rich Homolka's user avatar
  • 1,865
137 votes
27 answers
533k views

Why does fatal error "LNK1104: cannot open file 'C:\Program.obj'" occur when I compile a C++ project in Visual Studio?

I've created a new C++ project in Visual Studio 2008. No code has been written yet; Only project settings have been changed. When I compile the project, I receive the following fatal error: ...
Josh Sklare's user avatar
  • 4,054
137 votes
7 answers
986k views

What does "collect2: error: ld returned 1 exit status" mean?

I see the error collect2: error: ld returned 1 exit status very often. For example, I was trying to build the following snippet of code: void main() { char i; printf("ENTER i"); scanf(...
user3682120's user avatar
  • 1,373
136 votes
4 answers
170k views

How do I make a fully statically linked .exe with Visual Studio Express 2005?

My current preferred C++ environment is the free and largely excellent Microsoft Visual Studio 2005 Express edition. From time to time I have sent release .exe files to other people with pleasing ...
Bill Forster's user avatar
  • 6,227
134 votes
1 answer
67k views

What does the -all_load linker flag do?

I can't find anywhere what the -all_load flag does when compiling Objective-C code. I have some issues uploading binaries to Apple. They say it's because I didn't use this flag. However, my code ...
Guy Ephraim's user avatar
  • 3,500
131 votes
8 answers
173k views

static linking only some libraries

How can I statically link only a some specific libraries to my binary when linking with GCC? gcc ... -static ... tries to statically link all the linked libraries, but I haven't got the static ...
peoro's user avatar
  • 25.8k
122 votes
3 answers
90k views

Why do I get "unresolved external symbol" errors when using templates? [duplicate]

When I write C++ code for a class using templates and split the code between a source (CPP) file and a header (H) file, I get a whole lot of "unresolved external symbol" errors when it comes to ...
dlanod's user avatar
  • 8,761
121 votes
14 answers
244k views

What is compiler, linker, loader?

I wanted to know in depth meaning and working of compiler, linker and loader. With reference to any language preferably c++.
Sachin's user avatar
  • 1,283
121 votes
10 answers
84k views

What is the equivalent of Linux's ldd on windows? [closed]

What is the equivalent of Linux's ldd on Windows?
WilliamKF's user avatar
  • 42.1k
120 votes
5 answers
301k views

How to specify preference of library path?

I'm compiling a c++ program using g++ and ld. I have a .so library I want to be used during linking. However, a library of the same name exists in /usr/local/lib, and ld is choosing that library over ...
Heinrich Schmetterling's user avatar
114 votes
6 answers
114k views

What is __gxx_personality_v0 for?

This is a second-hand question from an OS development site, but it made me curious since I couldn't find a decent explanation anywhere. When compiling and linking a free-standing C++ program using ...
Bruce Johnston's user avatar
112 votes
16 answers
116k views

Splitting templated C++ classes into .hpp/.cpp files--is it possible?

I am getting errors trying to compile a C++ template class which is split between a .hpp and .cpp file: $ g++ -c -o main.o main.cpp $ g++ -c -o stack.o stack.cpp $ g++ -o main main.o stack.o ...
exscape's user avatar
  • 2,195
110 votes
6 answers
267k views

How to add include and lib paths to configure/make cycle?

I need a place to install libraries in a linux box I have no su access to. I'm using ~/local[/bin,/lib,/include], but I don't know how can I tell ./configure to look for libraries there (particularly, ...
Lacrymology's user avatar
  • 2,279
110 votes
5 answers
202k views

What does the "no version information available" error from linux dynamic linker mean?

In our product we ship some linux binaries that dynamically link to system libraries like "libpam". On some customer systems we get the following error on stderr when the program runs: ./authpam: /...
user avatar
109 votes
9 answers
200k views

Compilation fails with "relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object"

I'm trying to compile this source code from the makefile in a VPS, but its not working. The VPS is a 64 Cent OS Here's the full error # make gcc -c -O3 -w -DLINUX -I../SDK/amx/ ../SDK/amx/*.c g++ -c ...
user1667191's user avatar
  • 2,467
106 votes
1 answer
65k views

What are the --start-group and --end-group command line options?

What is the purpose of those command line options? Please help to decipher the meaning of the following command line: -Wl,--start-group -lmy_lib -lyour_lib -lhis_lib -Wl,--end-group -ltheir_lib ...
pic11's user avatar
  • 14.7k
100 votes
9 answers
39k views

What happens to static variables in inline functions?

I have a function that is declared and defined in a header file. This is a problem all by itself. When that function is not inlined, every translation unit that uses that header gets a copy of the ...
Dirk Groeneveld's user avatar
99 votes
2 answers
67k views

combine two GCC compiled .o object files into a third .o file

How does one combine two GCC compiled .o object files into a third .o file? $ gcc -c a.c -o a.o $ gcc -c b.c -o b.o $ ??? a.o b.o -o c.o $ gcc c.o other.o -o executable If you have access to the ...
Lucian Adrian Grijincu's user avatar
97 votes
5 answers
81k views

What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?

What is inside of a .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library? How come there is no need for a .lib file in dynamically linked dynamic ...
Sulla's user avatar
  • 7,781
95 votes
4 answers
62k views

Easy check for unresolved symbols in shared libraries?

I am writing a fairly large C++ shared-object library, and have run into a small issue that makes debugging a pain: If I define a function/method in a header file, and forget to create a stub for it (...
David Claridge's user avatar
95 votes
3 answers
39k views

Why is statically linking glibc discouraged?

Most of the sources online state that you can statically link glibc, but discourage from doing so; e.g. centos package repo: The glibc-static package contains the C library static libraries for -...
pzelasko's user avatar
  • 2,182
93 votes
8 answers
64k views

Replacing ld with gold - any experience?

Has anyone tried to use gold instead of ld? gold promises to be much faster than ld, so it may help speeding up test cycles for large C++ applications, but can it be used as drop-in replacement for ...
IanH's user avatar
  • 3,998
89 votes
7 answers
224k views

shared global variables in C

How can I create global variables that are shared in C? If I put it in a header file, then the linker complains that the variables are already defined. Is the only way to declare the variable in one ...
Claudiu's user avatar
  • 227k
87 votes
1 answer
26k views

What is the use of .exp and what is the difference between .lib and .dll?

During compilation and linking, what is use of .exp? What is the difference between .lib and .dll? I know that .lib will be used, while linking and .dll will be used when running the program. But what ...
Vineel Kumar Reddy's user avatar

1
2 3 4 5
282