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
13
votes
6 answers

Detect and use optional external C library at runtime in Objective-C

I am building an SDK that iPhone developers can include in their projects. It is delivered as a compiled ".a", without source code. Let's call my SDK "AAA". The customer in his project (let's call it "BBB"), in addition to use AAA, may also use a…
Nathan H
  • 48,033
  • 60
  • 165
  • 247
13
votes
2 answers

Installing OpenSSL library for Xcode

I have installed OpenSSL in xcode for receipt validation, but it doesn't work. I download openssl.xcodeproj and openssl-1.0.1f. I extract openssl-1.0.1f and add openssl.xcodeproj to my project. I edit the Header Search Path to : …
Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97
13
votes
1 answer

XCode5 Link Testflight SDK library

i want to use libTestFlight.a library in my project, i already import it in "Link Binaries With Libraries", also in build phases, i tried to add "Search Path" and "Header Path", i also tried to change the ARCH to Standard architectures (armv7,…
DeckyFx
  • 1,308
  • 3
  • 11
  • 32
13
votes
2 answers

Create podspec to ship static library

I'm trying to ship a static library via cocoapods. I was given the library without any build directions right now its a drop in to my iOS app. I don't need to build the library for each application using it, rather just download the lib files and…
JonMorehouse
  • 1,313
  • 6
  • 14
  • 34
13
votes
2 answers

How to teach Xcode to include all header files in output of static library project?

I followed a tutorial to create a static library project. Then I dragged in my classes and added them to the target. When I build & run, it creates a libUtils.a file. Upon reveal in Finder the include folder only contains the header file for the…
Proud Member
  • 40,078
  • 47
  • 146
  • 231
13
votes
3 answers

How do I fix warning MSB8012 in a static library project in Visual C++ 2010?

I am trying to convert a static library from VC++2008 to VC++2010, and I get these warnings about TargetPath and TargetName. I have had a look into my configuration and I'm not sure how to make these go away. Is it serious or is it really just an…
Warren P
  • 65,725
  • 40
  • 181
  • 316
13
votes
3 answers

Throwing C++ exceptions outside static library?

As a rule, exceptions must not propagate module boundaries as for example explained in Herb Sutters C++ Coding Standards (item 62). When compiled with different compilers or just compiler settings this might crash. I can understand the issue in case…
Kit Fisto
  • 4,385
  • 5
  • 26
  • 43
13
votes
2 answers

Initializing qt resources embedded in static library

I have next situation: I need to create widget in standalone static library, which then will be linked with final application (visual c++ 9.0, qt 4.5). This static widget library contains some resources (icons), and consist of a several .cpp files…
cybevnm
  • 2,586
  • 4
  • 30
  • 33
13
votes
1 answer

Visual Studio 2012 link errors with static libraries

I recently upgrade to 2012 from 2005 (I'm pretty sure) and ran into link errors when building my solution. I ran out of ideas after hours of searching google and putsing around. I've set up dozens of projects, so I'm pretty certain I've done…
13
votes
4 answers

Interface Builder can't see classes in a static library

I have refactored some UIView sub-classes into a static library. However, when using Interface Builder to create view components for a project that uses the static library I find that it is unaware of the library classes. What do I need to do to…
teabot
  • 15,358
  • 11
  • 64
  • 79
12
votes
4 answers

What is the meaning of "Warning: Linking the shared library against static library is not portable"?

I am making one dynamic library by using some function of libmxml.a library but I get this warning: *Warning: Linking the shared library libgstmatroskademux.la against the _ *static library /home/Mr32/gst-template4_final/gst-plugin/src/libmxml.a…
Jeegar Patel
  • 26,264
  • 51
  • 149
  • 222
12
votes
3 answers

What is a good technique for compile-time detection of mismatched preprocessor-definitions between library-code and user-code?

Motivating background info: I maintain a C++ library, and I spent way too much time this weekend tracking down a mysterious memory-corruption problem in an application that links to this library. The problem eventually turned out to be caused by…
Jeremy Friesner
  • 70,199
  • 15
  • 131
  • 234
12
votes
2 answers

Is using --start-group and --end-group when linking faster than creating a static library?

If one builds static libraries in one's build scripts and one wants to use those static libraries in linking the final executable, the order one mentions the .a files is important: g++ main.o hw.a gui.a -o executable If gui.a uses something defined…
Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212
12
votes
5 answers

`ar` library override timestamp

the .a archive format header requires a timestamp. This has led to countless headaches when I rebuild a static library, mainly because I can't exactly reproduce the original binary. For example (this is on my Mac, but the same thing happens in x64…
Foo Bah
  • 25,660
  • 5
  • 55
  • 79
12
votes
2 answers

How to export Flutter project as SDK (iOS dynamic framework)

We have built an awesome Flutter project, which has great functionality we want to export as a framework, just like native libraries do, so that the source code is hidden (convert to dynamic framework). We have followed the instructions:…
Almas Adilbek
  • 4,371
  • 10
  • 58
  • 97