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

Porting cross-platform C++ libraries to Windows Phone 8 platform

I've searched the web and StackOverflow a lot, but can't seem to find a definitive answer to my following questions. Context: I am looking to port a group of C++ helper libraries for use with the Windows Phone 8 (WP8) platform. Historically, these…
15
votes
2 answers

How to convert an Xcode project into a static library or framework?

I have a project which I need to import into other project as a framework just like how we import Coredata framework, Quartzcore etc..How to achieve that ? How to compile my project into a library or framework which can be imported into other…
stack2012
  • 2,146
  • 2
  • 16
  • 23
15
votes
1 answer

Best practice for sharing code between OSX and IOS app

I am creating an iOS version of an existing OSX app and am wondering what the best practices are for sharing code between the two. The code in question only depends on the foundation framework and the Sqlite dynamic library, so it should compile and…
Alberto
  • 403
  • 3
  • 11
14
votes
2 answers

Why would the size of the final binary be so much smaller than the size of the static library?

This is an iOS question. I build a static library (a framework in iOS) which is then included in an app. The size of the result binary (500kb) is smaller than the size of the static library (6mb). How does this work? My understanding of static…
Evil Nodoer
  • 1,927
  • 3
  • 23
  • 32
14
votes
3 answers

Combining static libraries

Suppose I have three C static libraries say libColor.a which depends on *libRGB.*a which in turn depends on libPixel.a . The library libColor.a is said to depend on library libRGB.a since there are some references in libColor.a to some of symbols…
AIB
  • 5,894
  • 8
  • 30
  • 36
14
votes
1 answer

Why does not Xcode generate dSYM for static library

I try to compile library and get debug symbols with "DWARF with dSYM File" format. This works for dynamic but not for static libraries. XCode "Quick help" says that "dSYM file is not needed and will not be created for static library or object file…
Igor
  • 1,029
  • 9
  • 21
14
votes
4 answers

Is it possible to unit test a static library project using XCode's SenTestingKit?

I've created an iOS unit test target for doing logic tests following the steps provided in Apple's documentation. However my build fails and i get the following error: Undefined symbols: "_OBJC_CLASS_$_MyClass", referenced from: …
Patrick
  • 1,079
  • 1
  • 9
  • 14
14
votes
2 answers

How to properly uninitialize OpenSSL

In my OpenSSL client I have the problem that the very moment I chose to link libeay32 and ssleay32 statically instead of dynamically I got tons of memory leak errors from Visual Leak Detector. I copied the commands from the OP in this thread, but I…
Alex
  • 1,198
  • 2
  • 12
  • 26
14
votes
1 answer

FFMPEG for Android toolchains: arm-linux-armeabi-eabi-pkg-config - is there any toolchain in existence containing the pkg-config tool

Does anybody know any toolchain for ffmpeg linux arm platform which contains the arm-linux-androideabi-pkg-config tool? The Android NDK does not contain it. Also has anybody succeeded in building ffmpeg for android that contains the alsa device?…
13
votes
2 answers

A static library vs. an import library on the Windows platform

How could I tell one .lib file is a static library vs. an import library for a DLL file? Is there a tool or command that could do this? The second question is: How could I check the dependencies of a static library? I mean, how could I know which…
cobe24
  • 221
  • 3
  • 8
13
votes
1 answer

Slow compile times with react-native iOS app

I am currently working on a react-native iOS app. While developing I noticed that the compile times for the app are really slow. I got a CI hooked up which roughly does the following: clean git checkout of the applications workspace run unit…
dehlen
  • 7,325
  • 4
  • 43
  • 71
13
votes
1 answer

Boost.Test tests on a static library

I'm using Boost.Test for unit testing. Because of several reasons, I would like to write the unit test cases on different static libraries. The problem is that when I do this, the automatic registrar doesn't work. For instance, if I have something…
Gaston
  • 1,828
  • 2
  • 15
  • 29
13
votes
1 answer

gcc library option with a colon, -l:libevent.a

I'm going through a Makefile. Found this interesting bit of code, LIBS = -l:libevent.a. Was digging through gcc documentation but didn't find anything relevant. Does anyone know what it means?
flashburn
  • 4,180
  • 7
  • 54
  • 109
13
votes
1 answer

What means: libtool: -dynamic not specified the following flags are invalid: -ObjC

I inherited a project (lucky me!) which relies on a static library. Trying to build the static lib, I get this error: /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool: -dynamic not specified the following flags are invalid:…
Olie
  • 24,597
  • 18
  • 99
  • 131
13
votes
1 answer

Turn thin archive into normal one

I'm building V8, and by default it builds as a "thin" archive, where the .a files essentially just contain pointers to the object files on your filesystem instead of containing the object files themselves. See man ar for details. I want to be able…
Matt Kline
  • 10,149
  • 7
  • 50
  • 87