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

Can you statically compile a cygwin application?

Does cygwin allow a statically compiled binary? This would prevent the need for cygwin1.dll being on the PATH of target machines.
JayG
  • 4,339
  • 3
  • 23
  • 19
26
votes
7 answers

How can adding a function call cause other symbols to become undefined when linking?

I'm hoping someone will be able to help troubleshoot what I think is a linker script issue. I'm encountering a strange problem after adding a call to a new function. Without the function call, my object files link correctly, however, with the new…
owst
  • 518
  • 4
  • 14
26
votes
4 answers

How can I change the filename of a shared library after building a program that depends on it?

I have a program that depends on a shared library it expects to find deep inside a directory structure. I'd like to move that shared library out and into a better place. On OS X, this can be done with install_name_tool. I'm unable to find an…
ZorbaTHut
  • 1,163
  • 1
  • 11
  • 19
26
votes
2 answers

C++ linking error after upgrading to Mac OS X 10.9 / Xcode 5.0.1

After upgrading to Mac OS X 10.9 / Xcode 5.0.1, command lines to create a shared library (.dylib) failed with several undefined symbols. clang++ -dynamiclib -install_name test.dylib *.o -o test.dylib Undefined symbols for architecture x86_64: …
FabienRohrer
  • 1,794
  • 2
  • 15
  • 26
26
votes
4 answers

Undefined reference to `initscr' Ncurses

I'm trying to compile my project and I use the lib ncurse. And I've got some errors when compiler links files. Here is my flags line in Makefile: -W -Wall -Werror -Wextra -lncurses I've included ncurses.h Some layouts : prompt$> dpkg -S…
BoilingLime
  • 2,207
  • 3
  • 22
  • 37
26
votes
3 answers

GCC and linking environment variables and flags

The following link in the official documentation for GCC: https://gcc.gnu.org/onlinedocs/gcc/gcc-command-options/environment-variables-affecting-gcc.html Explains the following environment…
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
25
votes
4 answers

How to statically-link a complex program

In Linux, downloaded a program source and want it to be statically linked. Have a huge Makefile there, I ./configure make to compile. prehpes it's a bit too general to ask, but how can I make the binary statically linked? EDIT: the reason for this…
Liran Orevi
  • 4,755
  • 7
  • 47
  • 64
25
votes
4 answers

Gurus say that LD_LIBRARY_PATH is bad - what's the alternative?

I read some articles about problems in using the LD_LIBRARY_PATH, even as a part of a wrapper script: http://linuxmafia.com/faq/Admin/ld-lib-path.html http://blogs.oracle.com/ali/entry/avoiding_ld_library_path_the In this case - what are the…
SyRenity
  • 841
  • 5
  • 11
  • 18
25
votes
3 answers

Linking *.lib files with MinGW

Is it possible to Link *.lib files with MinGW (I use it with Eclipse)? I'm fighting with libcurl+OpenSSL and I don't understand if my errors are because I try to use .lib-files in MinGW or something else is…
Alecs
  • 2,256
  • 8
  • 32
  • 45
25
votes
9 answers

Visibility of template specialization of C++ function

Suppose I have fileA.h which declares a class classA with template function SomeFunc(). This function is implemented directly in the header file (as is usual for template functions). Now I add a specialized implementation of SomeFunc() (like for…
oliver
  • 6,204
  • 9
  • 46
  • 50
25
votes
5 answers

g++: In what order should static and dynamic libraries be linked?

Let's say we got a main executable called "my_app" and it uses several other libraries: 3 libraries are linked statically, and other 3 are linked dynamically. In which order should they be linked against "my_app"? But in which order should these be…
25
votes
6 answers

Tips on reducing c++ linking time

I have a project that takes about 8 seconds to link with g++ and ld. It uses a bunch of static libraries, most of the code is c++. I'm interested in a general list of tips on how to reduce link time. Anything from "dont include debug symbols" to…
Lucas Meijer
  • 4,424
  • 6
  • 36
  • 53
25
votes
12 answers

Error while loading shared libraries: /usr/local/lib64/libssl.so.1.1

I’m trying to compile openssl-1.1.0e on Centos 7 (7.3.1611) but after i successfully compiled everything without any warning, i get an error when i’m trying any openssl command [mdm@dev openssl-1.1.0e]$ openssl version openssl: error while loading…
fromthestone
  • 1,217
  • 2
  • 13
  • 16
25
votes
4 answers

initializing a static variable in header

I am new in programming in C, so I am trying many different things to try and familiarize myself with the language. I wrote the following: File q7a.h: static int err_code = 3; void printErrCode(void); File q7a.c: #include #include…
darven
  • 367
  • 1
  • 5
  • 7
25
votes
2 answers

xcode project-/target-settings-syntax for linker flag force_load on iPhone

I am confronted with the double bind. On the one hand, for one of the 3rd party static libraries my iPhone application uses, the linker flag -all_load has to be set in the application project or target settings. Otherwise, the app crashes at…
Kaiserludi
  • 2,434
  • 2
  • 23
  • 41