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
1 answer

Static library gives strange errors on Xcode

I made a static library(.a) following the instructions of Ray Wenderlich, compiled it without errors and warnings, and then I included it on a new project. When I tried to build the new project, I got this…
Kurr0
  • 197
  • 1
  • 10
2
votes
0 answers

How to build a static library with third party framework in Objective-C

I am trying to build a static library which is using a third party framework in Objective-C. I created static libs following this article http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/ It is built successfully. But, when i am…
Patryk
  • 21
  • 3
2
votes
0 answers

What is the best way to add iOS Google API components (Analytics) to a static iOS library?

I am building a static iOS library and would like to use Google Analytics for tracking events inside the library. I tried installing via CocoaPods in the library itself but when I run the parent app I get a "resource not found" error. When I add the…
oviroa
  • 1,079
  • 2
  • 12
  • 29
2
votes
1 answer

Problems loading .wav files with AudioKit

I am using a static library from AudioKit to playback audio samples for this music app i'm working on. However, when following the tutorial for sample playback from AudioKit.io I am getting these errors. fieldTheory1[28918:3777755] Csound Error:…
2
votes
1 answer

Q_INIT_RESOURCE not working

Im developing a static library, and I use a qrc file. I read the documentation and found, that I have to call Q_INIT_RESOURCE to make it work, but no success so far. I called Q_INIT_RESOURCE in main, directly after creating the QApplication (I…
Felix
  • 6,885
  • 1
  • 29
  • 54
2
votes
1 answer

Using Static/Shared C Libraries in Higher Level Languages

I'm wondering if there is some way to take my custom shared/static libraries, made in C, and use them into another higher language such as python or node.js. I came with this because I'm writing a few libraries to calculate some math stuff. I heard…
user4713908
2
votes
1 answer

C++ Static members of a class are initialized after constructor

I have a problem with static members of a class not being initialized before the constructor. Am i doing something wrong? Is it a bug in G++ ? Any workarounds? g++ --version : (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 I am also using Eclipse as my IDE,…
Mattahy
  • 23
  • 4
2
votes
2 answers

Static library dependency compiles in simulator on Xcode 3.2.3, fails on device

Upgrading to XCode 3.2.3 and iPhone 3.2/4.0 SDK has introduced a strange bug into my build process. I have a static library, Compton, which itself depends on three20. I build Compton as a dependency of the client apps that it powers. When I compile…
prairiedogg
  • 6,323
  • 8
  • 44
  • 52
2
votes
2 answers

Problem with linking against a static library which has inline functions

i have a static library which (among other things) implements a tiny function that only returns some string from a table of const strings. This function is not called anywhere inside the library, but still it's declared as inline. For clarity, it…
PeterK
  • 6,287
  • 5
  • 50
  • 86
2
votes
1 answer

pthread static linking with application in visual studio 2013

I want to pthread lib statically linked with my application so that at other target without install pthread lib my .exe will run. For that I have add pthreadVC.lib in Linker->input->additional dependency of visual studio and also given correct path…
Mohan
  • 1,871
  • 21
  • 34
2
votes
0 answers

Is there a way to preserve debug information for a static library that is purely an aggregate of other static libraries?

I have a project that builds a static library that is purely an aggregate of other static libraries. This is achieved by adding the input libraries to the project as files. However, even if debug information is available for the input libraries,…
2
votes
0 answers

C++ Cross Platform Library (iOS and Android) using math.h

I am using VS2015 RC and the cross platform C++ Shared Library Template. Under the .Shared code I added a simple point class. When it created the class, in the .cpp it included pch.h or a pre-compiled header that is only available in .android and…
2
votes
1 answer

makefile include static library - C

I have 2 projects. The first has 4 files in it: 1. main.c (which include PNM.h) 2. PNM.c (which include PNM.h) 3. PNM.h 4. makefile CC=gcc LD=gcc CFLAGS=--std=c99 -Wall -W…
Adrien
  • 25
  • 8
2
votes
1 answer

How to make sure statically linked Boost is used in dynamic library file

I have an executable E which (I assume) dynamically loads (dlopen) a library file A.so. File A.so dynamically links B.so which is produced by me. In B.so I statically link a number of libraries, e.g. Boost (let's call this static boost library C1).…
Coert Metz
  • 894
  • 6
  • 21
2
votes
1 answer

VS2013: LNK1104 error when linking with project in same solution

This is probably one of the sillier questions on SO, but I can't solve it. I've got a solution containing three projects A, B and C. A and B are static lib projects, and C is an exe project which links with A and B. I've set up the build directories…
Paul
  • 443
  • 8
  • 18