A static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable. This executable and the process of compiling it are both known as a static build of the program.
Questions tagged [static-linking]
1772 questions
14
votes
0 answers
How to statically link an existing linux executable?
Looking for a way to convert a dynamically linked executable to a static executable. Seems like it should be possible but man pages are turning up short and google's not helping either.

Dan Head
- 159
- 1
- 4
14
votes
3 answers
Trying to statically link Boost
I am working in Linux, Eclipse CDT, g++, with Boost library. Having existing program which uses Boost thread, I try to link it statically instead of dynamically. /usr/local/lib directory contains the following…

Alex F
- 42,307
- 41
- 144
- 212
14
votes
2 answers
Static linking of Glibc
How can i compile my app linking statically glibc library, but only the code needed for my app? (Not all lib)
Now my compile command:
g++ -o newserver test.cpp ... -lboost_system -lboost_thread -std=c++0x
Thanks!

Breakdown
- 1,035
- 4
- 16
- 26
14
votes
2 answers
How can an autotools user specify a combination of static & dynamic linking?
I'm building a program with autoconf, automake, and libtool.
My work requires that I statically link (most) libraries. This hasn't been
a problem in the past because I could statically link everything with
-all-static. Now it's a problem because I…

tprk77
- 1,151
- 1
- 9
- 22
14
votes
3 answers
In C, is it possible to change exported function name to different one?
all.
I want to link a library which calls malloc() function.
However, my target environment is different one and
malloc() is supplied as inline-function.
How can I make the library's call to malloc() direct to
my target environment's malloc()…

Chul-Woong Yang
- 1,223
- 10
- 17
13
votes
1 answer
VS2010: Link in a single library statically
Situation:
I'm building a library with VS2010, and it has a dependency on LibraryA. I am only using one of many features that LibraryA offers, so I want to link it in statically.
Everything I'm reading about this tells me to set the whole project…

Ben
- 7,692
- 15
- 49
- 64
13
votes
2 answers
How can I produce a Crystal executable with no dependencies?
I'm writing a program in Crystal, that I intend to compile and move to other systems for execution. Ideally, it should have no dependencies, as the target systems will be fresh installations of linux.
Sadly, I can't get around the libc dependency,…

Sod Almighty
- 1,768
- 1
- 16
- 29
13
votes
1 answer
linking opencv libraries included as an external project via cmake
I'm relatively new to cmake and after days of struggling couldn't figure out the following thing:
I have a project that depends on opencv (which is a cmake project on its own) and I want to statically link opencv libraries. What I'm doing is I have…

Vyacheslav
- 1,186
- 2
- 15
- 29
13
votes
4 answers
C++ application - should I use static or dynamic linking for the libraries?
I am going to start a new C++ project that will rely on a series of libraries, including part of the Boost libraries, the log4cxx or the google logging library - and as the project evolves other ones as well (which I can not yet anticipate).
It will…

Salo
- 298
- 2
- 8
12
votes
3 answers
Creating C++ API Library
I'm trying to understand the correct way, or right approach, to provide a reasonably large C++ API for a non-open source project. I do not want to provide a "header only" library as the code base is fairly large and meant to be closed source. The…

humbleprogrammer
- 121
- 1
- 1
- 3
12
votes
1 answer
Cython: Compile a Standalone Static Executable
I'm trying to compile an executable (ELF file) that does not use a dynamic loader.
I used Cython to compile Python to C:
cython3 -3 test.py --embed
Then
gcc test.c -otest $(pkg-config --libs --cflags python3)
to compile C generated file.
Now I'd…

GinoC
- 442
- 4
- 16
12
votes
3 answers
Can I link MSVCRT statically with mingw?
I have C program I compile with mingw on Windows. It works fine but requires MSVCRT.DLL. I want to link that statically (like I can do in Visual Studio). Is this possible?
I tried -static flag to gcc and it didn't make any change.
What about C++…

zaharpopov
- 16,882
- 23
- 75
- 93
12
votes
1 answer
Linking against boost barfs with 'undefined reference to `boost::system::get_system_category()'
I'm having trouble statically linking an app which uses the boost 1.35 libraries. I'm using a linux debian Lenny box, with G++ 4.3.2. Linking without -static works without a hitch.
Specifically,
g++ -Wall -Wextra -pedantic -ggdb3 -O0 -static -l…

Santiago Árraga
- 348
- 1
- 4
- 12
12
votes
3 answers
What happens to static variables when libraries are statically linked
Let's say I have library (A) implementing the singleton pattern (it has a static variable in its implementation).
(A) library is compiled as a static library.
Now, let's say I have in my probject:
(B), another static library linking statically with…

jpo38
- 20,821
- 10
- 70
- 151
12
votes
1 answer
Why doesn't the linker complain of duplicate symbols?
I have a dummy.hpp
#ifndef DUMMY
#define DUMMY
void dummy();
#endif
and a dummy.cpp
#include
void dummy() {
std::cerr << "dummy" << std::endl;
}
and a main.cpp which use dummy()
#include "dummy.hpp"
int main(){
dummy();
…
user5362441