Questions tagged [static-linking]

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.

1772 questions
23
votes
3 answers

C-library not linking using gcc/g++

I have a c-library which I use in gcc. The library has the extension .lib but is always linked as a static library. If i write a program which uses the library as c-code, everything as a-ok. If I however rename the file to .cpp (doing simple stuff…
Adrian
22
votes
4 answers

c++ linux double destruction of static variable. linking symbols overlap

Environment: linux x64, compiler gcc 4.x Project has following structure: static library "slib" -- inside this library, there is static object "sobj" dynamic library "dlib" -- links statically "slib" executable "exe": -- links "slib" statically --…
John
  • 749
  • 8
  • 17
22
votes
2 answers

How to add static libraries to a Visual studio project

I am trying to add static libraries to my project. To add the static library I am following Microsoft's instructions: http://msdn.microsoft.com/en-us/library/ms235627.aspx. My problem is I that am not able to see the dependent library while adding…
Bhupesh Pant
  • 4,053
  • 5
  • 45
  • 70
21
votes
1 answer

Static-linking of SDL2 libraries

I am using Windows 7, Code::Blocks and MinGW. I have little to no experience when it comes to compiling/building anything, especially when Code::Blocks doesn't use makefiles. I downloaded SDL2-devel-2.0.0-mingw.tar.gz (SDL Development Libraries)…
DispEd
  • 219
  • 1
  • 2
  • 5
21
votes
3 answers

C++ Visual Studio: linking using pragma comment

I came across a piece of code which uses #pragma comment(lib, "libraryname"). Why this type of usage as opposed to just linking the library from the properties menu? In what situations is this usage called for? I am in windows using C++…
user1612986
  • 1,373
  • 3
  • 22
  • 38
21
votes
2 answers

CMake on Linux: "target platform does not support dynamic linking"

I have the very simple CMakeLists.txt CMAKE_MINIMUM_REQUIRED(VERSION 2.8) FIND_PACKAGE(VTK REQUIRED) PROJECT(test CXX) that really doesn't do anything. The package VTK is correctly found under /usr/lib/vtk-5.8/VTKConfig.cmake. This file includes a…
Nico Schlömer
  • 53,797
  • 27
  • 201
  • 249
20
votes
3 answers

How do I specify the linker path in Rust?

I'm trying to link a Rust program with libsoundio. I'm using Windows and there's a GCC binary download available. I can link it like this if I put it in the same folder as my project: #[link(name = ":libsoundio-1.1.0/i686/libsoundio.a")] #[link(name…
Timmmm
  • 88,195
  • 71
  • 364
  • 509
20
votes
1 answer

How can i link my c++ program statically with libstdc++ on osx using clang?

i'm writting c++ program and i want to distribute it on Mac OS X versions 10.6 and above. The problem is when i compile the program with clang and it's dynamically linked with libstdc++ and it causes problems with older systems. There is a key…
milo
  • 1,220
  • 3
  • 17
  • 33
20
votes
5 answers

C++ linking problems, seems like I can't link against standard C++ stuff

I am trying to use a library I've compiled myself in an iOS app. The library is the Tesseract OCR lib. It seems like compiling that (and its dependencies) have gone ok. However, when I try to link against this lib in my app project, the app fails…
D.C.
  • 15,340
  • 19
  • 71
  • 102
20
votes
5 answers

Is there an option to GNU ld to omit -dynamic-linker (PT_INTERP) completely?

I'm experimenting with the concept of pure-static-linked PIE executables on Linux, but running into the problem that the GNU binutils linker insists on adding a PT_INTERP header to the output binary when -pie is used, even when also given -static.…
R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
19
votes
2 answers

link a static library to a shared library and hide exported symbols

I am having an annoying problem with the linker. I want to link some symbols from a shared library to a static library, but not export its symbols (ie, I cannot simply merge the libraries or link with --whole-archive). What I want is link (as in,…
Thibaut
  • 2,400
  • 1
  • 16
  • 28
18
votes
1 answer

Significant performance difference of std clock between different machines

Testing something else I stumbled across something that I haven't managed to figure out yet. Let's look at this snippet: #include #include int main () { int i = 0; using namespace std::chrono_literals; auto const end =…
hassec
  • 686
  • 4
  • 18
18
votes
4 answers

How to use static linking with OpenSSL in C/C++

I wrote simple apps with Openssl in C and C++. I compile them like this: gcc openssltest.c -o openssltest -lcrypto g++ openssltest.cpp -o openssltest -lcrypto And its all ok but only, when you have Openssl installed. I would like to compile it that…
yak
  • 3,770
  • 19
  • 60
  • 111
17
votes
5 answers

Xcode 4 Final - "armv6 armv7" issue while linking with armv6 libs

Until xcode 4 final (I was using 3.latest and 4 GM for the time it was available) this didn't happen. When I upgraded to xcode 4 final version, I started getting a linking error while trying to link the armv7 version with my non armv7 library (my…
cusquinho
  • 387
  • 1
  • 4
  • 14
17
votes
2 answers

Static link libstdc++ using clang

When I use GCC, I can build program on my Ubuntu 15.04 using this: -static-libgcc -static-libstdc++ And compiled binary can run on "stock" Ubuntu 14.04 without any external packages, only standard updates. Is there possibility do build with this…
vladon
  • 8,158
  • 2
  • 47
  • 91