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
2 answers

Static lib loading related issue

Suppose I want to version the libs in binaries made. For static libs, I thought this approach would work but it does not: LibInfo.h - Base class for all libinfo classes. Registers an object in gvLibInfo vector when a child is constructed. #ifndef…
nakiya
  • 14,063
  • 21
  • 79
  • 118
2
votes
2 answers

SConscript StaticLibrary attribute error.

I couldn't find any information on the net, so I kindly ask you for one. I have my build environment set up properly, My compiler is 'cl' from VS express package. I try to build static library, when i set my tools to 'default' everything works, but…
bua
  • 4,761
  • 1
  • 26
  • 32
2
votes
1 answer

How can I link statically to another project, which itself needs to link to other static libraries?

I have two projects in a solution (VS 2015). One project (A) is the entry project and generates an executable. The second project (B) generates a static library. I set B as a reference in A. However B needs itself to link against some precompiled…
2
votes
1 answer

Differences between a shared object and an ordinary library in Linux

What are the main differences between binding to a shared object or to an ordinary object? Also how is this possible to share some variables between some programs and knowing that our variables are never changed by another program?
Amir Zadeh
  • 3,481
  • 2
  • 26
  • 47
2
votes
1 answer

Qt error when adding library - no rule to make target

I am trying to build a plain c++ qmake project in Qt, I have linked the library required by my code using the built in "add library..." wizard. I have set the library as static. This then modifies my .pro file with this additional text: win32: LIBS…
Harry de winton
  • 969
  • 15
  • 23
2
votes
1 answer

How does a .lib file differ from a mere .a file created with ar?

We are porting our linux development to windows. To create a static library, we still use ar under windows (Msys2) to create a libXXX.a file. The windows way is actually to create a .lib file using some windows tool. But the libXXX.a file seems to…
gexicide
  • 38,535
  • 21
  • 92
  • 152
2
votes
0 answers

CMake link ordering when using multiple implementations of interface libraries

I have a project with a layer consisting of interface libraries: add_library(I INTERFACE) These interface libraries are then implemented several times, to fit the different environments of applications: add_library(IA STATIC…
Etan
  • 17,014
  • 17
  • 89
  • 148
2
votes
4 answers

C questions about static and shared libraries

I have some .c and .h files with the main function encapsulated in the MAIN_FUNC.c. I need to pass them to a guy who is going to integrate the MAIN_FUNC() with his files. However since my algorithm is confidential I can't just send the .c and .h…
João Pereira
  • 673
  • 1
  • 9
  • 29
2
votes
1 answer

Including the new Firebase Library in Cocos2d-x projects

This is a two part question: I cannot compile my cocos project via cli as the following error pops up: jni/../../Classes/CustomEngine/AnalyticsEngine/firebase/analytics.h:9:26:fatal error: firebase/app.h: No such file or #include…
ThorX2
  • 176
  • 8
2
votes
1 answer

Is it necessary to include static dependency libraries of static dependency library

I have created a static library(libPdfWrapper.a) which will use it dependency libraries then i am using libPdfWrapper.a in pdf project but its looking for libPdfWrapper.a dependencies also thought it is static library. libPdfWrapper.a .pro file…
Jeggu
  • 569
  • 2
  • 10
  • 26
2
votes
1 answer

What causes a compiled library to store its build command internally?

Sometimes when I build a package from source, the resulting binaries seem to contain a reference to the build flags I'm using. The example I'm working with is the fftw library. Here's how to download and build it. FWIW, these lines take about ~30…
Stuart Berg
  • 17,026
  • 12
  • 67
  • 99
2
votes
2 answers

Add /usr/local to path for ./configure

I am trying to install libvisio-0.1.5 which requires librevenge-0-0. I get the error: checking for REVENGE... no configure: error: Package requirements ( librevenge-0.0 ) were not met: I just installed librevenge and I have all the…
nowox
  • 25,978
  • 39
  • 143
  • 293
2
votes
0 answers

CMake: build fails when compiling a C++ shared lib depending on MPI

Problem overview I'm using CMake to build a project which contains a library based on MPI. The lib has to be built as both shared and static. When I build the project on my Fedora 20 system, everything goes without problem. When I build it on a Mac…
M4urice
  • 571
  • 6
  • 15
2
votes
0 answers

Create CocoaPod with OpenSSL-Universal as Dependency

I'm trying to create a CocoaPod that has OpenSSL-Universal as a dependency. Whenever I go to the auto-generated Example subfolder and run pod install, I get the following error message: [!] The '…' target has transitive dependencies that include…
arik
  • 28,170
  • 36
  • 100
  • 156
2
votes
1 answer

Can't import library libcore.io.IoBridge

I'm trying to run an open source project in Android Studio 2.0. My problem is that I can't import the class IoBridge (import libcore.io.IoBridge;). The compiler is saying that libcore does not exist. And effectively in my SDK (revision 23) there is…
pape
  • 47
  • 7