Questions tagged [static-libraries]

A static library is an archive of object files. Used as a linker input, the linker extracts the object files it needs to carry on the linkage.

The needed object files are those that provide the linker with definitions for symbols that it finds are used, without definition, in other input files. The needed object files, and no others, are extracted from the archive and input to the linkage exactly as if they were individual input files in the linkage command and the static library was not mentioned at all.

Linkers may differ as to whether the position of a static library in the sequence of input files affects its availability to be searched for needed object files. Some linkers (e.g. GNU ld) will search a static library only to obtain definitions for unresolved symbol references used in earlier input files. For such a linker, success requires a static library to be input after all other files that depend on it for symbol definitions. Other linkers (e.g. Microsoft link) will search a static library to obtain a definition for any otherwise unresolved symbol reference.

A linker will normally support an option (GNU ld: --whole-archive, MS link: /WHOLEARCHIVE) to override the default processing of static libraries and instead link all the contained object files, whether they are needed or not.

A static library contributes nothing to a linkage except the object files that are extracted from it, which may be vary in different linkages. It is to be contrasted with a shared library, another kind of file altogether with a very different role in linkage.

4482 questions
2
votes
4 answers

No additional dependencies required for a LIB but are required for a DLL

I have a framework (in C++) which is dependent on a few third party libraries. When I compile a static version of the library framework, no additional dependencies are needed, that is, the lib files of the third part libraries are not needed. When I…
Samaursa
  • 16,527
  • 21
  • 89
  • 160
2
votes
2 answers

Is it possible to link FFmpeg statically into an application built with Visual C++?

I'm currently building and using FFmpeg on Windows and it works nicely. At present there are 5 relevant DLLs which I load and map relevant functions in as needed. However I am wondering if it is possible to avoid these DLLs by linking FFmpeg…
Richard Viney
  • 957
  • 16
  • 31
2
votes
1 answer

How to compile library for multiple platforms

I'm Windows user, and I'm using VS2015 to compile my С++ projects for Windows. But I need to compile my library for multiple platfroms, such as Linux, Android, HTML5, PlayStation 4, iOS. But I have no any experience with this. My target is uploading…
Artem Selivanov
  • 1,867
  • 1
  • 27
  • 45
2
votes
2 answers

Equivalent command to build (on WDK 7) with WDK 10

I have some really old scripts using the build command for compiling with WDK 7. A sample command to build a static library is: build /F /g /w /b /c /Z /jpath %BUILDROOT% What is equivalent command I can use to compile the same with WDK 10? Also…
2
votes
1 answer

Loading Classes From Static Library in D

I read how to load functions from a static library from this answer: https://stackoverflow.com/a/10366323/6123767 But I need to load a class from the static library, not just a function, how can I achieve it?
Nafees
  • 509
  • 4
  • 16
2
votes
0 answers

How to build dlib for iOS

I'm trying to build dlib for iOS. I have generated a libdlib.a file but when checking with otool -lv libdlib.a | grep LC_VERSION I get: cmd LC_VERSION_MIN_MACOSX How can I build for iOS instead?
2
votes
1 answer

Why doesn't Swift support static libraries in iO

Why doesn't Swift support static libraries? I saw this explanation, but I don't understand this reasoning. The current runtime doesn't ship with the OS, so static libs would lead to multiple runtimes in the final executable. A statically linked…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
2
votes
1 answer

Build targets with different templates in Qt

Hi I am relatively new to Qt and I could not find a viable solution to this so far. I have the following project structure ALPHA-app alpha.pro ALPHA-Desktop alpha-desktop.pro ALPHA-Shared alpha-shared.pro …
clearScreen
  • 1,002
  • 4
  • 15
  • 31
2
votes
1 answer

Is it possible with Delphi to create a static library for iOS?

I would like to use existing Pascal source (no user interface) in an iOS app (Xcode project). So I need to create a static library, which I can then add to my iOS project. Is there a way to create a static library (*.a) for the arm architecture…
Stefan
  • 63
  • 1
  • 2
  • 8
2
votes
2 answers

how to remove pthread undefined reference while building single thread library

I am getting undefined reference for pthread API's and I don't know how to resolve them? Here is the scenario: libA.a -- this is 3rd party library [it contains lots of API's which are pthread dependent] libB.a -- This is my own library. I am using…
Jatin
  • 1,857
  • 4
  • 24
  • 37
2
votes
2 answers

Link errors using cryptopp on VS2012 static library, console application and clr program

I have the following project structure on VS2012 C++: cryptopp: As downloaded and build from cryptopp project. AccessLib: A static library build using cryptopp functions. TestApp: A Win32 console application that uses AccessLib (and cryptolib…
Mendes
  • 17,489
  • 35
  • 150
  • 263
2
votes
1 answer

Boost.Log failing to link with static libraries because of missing code_convert

I'm trying to link Boost.Log statically into my program. Boost.Log has successfully compiled with other modules using bjam. However, when I try to link with my program I'm getting an error: g++ -g -O2 -pthread -o sonar sonar-main.o sonar-config.o…
Mikey A. Leonetti
  • 2,834
  • 3
  • 22
  • 36
2
votes
2 answers

incorporate .so into another .so without dependency?

i have a c program that relies on a second library whose compilation i can control. i want to be able to compile my program into a shared object library without it linking to the second library. in other words i want a single monolithic shared…
Heinrich Schmetterling
  • 6,614
  • 11
  • 40
  • 56
2
votes
1 answer

How do you produce one static library for both release/debug on the iPhone?

I would like to release a static library similar to what PayPal did (https://www.x.com/community/ppx/xspaces/mobile/mep) for the iPhone. They were successful in incorporating both the release/debug version of their static libraries into one single…
Shiun
  • 2,677
  • 1
  • 20
  • 20
2
votes
2 answers

Build FFTW lib with Visual Studio 2015 [added: steps for VS 2019]

I'm trying to use Visual Studio 2015 to compile a project that uses FFTW. Unfortunately, the precompiled binaries from the FFTW website aren't compatible with VS 2015, due to this problem: unresolved external symbol __imp__fprintf and…