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

Undefined symbols for architecture x86_64 - Mavericks (Yosemite, El Capitan...)

EDIT : If you fall on this post, you may want to jump directly to the answer I sent a post about my confusion earlier this morning machine type (C++ librairies) : i386 vs x86_64 But I guess I did a mistake by being not precise. So I decided to…
Issam T.
  • 1,677
  • 1
  • 14
  • 32
17
votes
3 answers

Why do some DLL files need an additional .lib file for linking?

I have a question about library linking and .lib files... this is the context: OS = Windows IDE = QT I have created a DLL: MyLib.dll. To use that library in my QT project, I only have to include an include path, a link to the library and use the…
17
votes
3 answers

Building a static library with cocoapods

I am trying to build a static library that has different dependencies (AFNetworking for example) specified in a Podfile. I don't want the dependencies to be included in the final static library (call libMyProject.a), I just want to link against them…
javierdfm
  • 359
  • 1
  • 4
  • 10
17
votes
2 answers

How to avoid #include dependency to external library

If I'm creating a static library with a header file such as this: // Myfile.h #include "SomeHeaderFile.h" // External library Class MyClass { // My code }; Within my own project I can tell the compiler (in my case, Visual Studio) where to look…
JBentley
  • 6,099
  • 5
  • 37
  • 72
17
votes
1 answer

What are best practices to decrease the size of static libraries in objective-c?

In building an objective-c static library, I noticed that the .a file (fat file from simulator and iPhone) is quite large. In particular, it was originally 5.7mb. I found this post and set my build settings Generate Debug Symbols to No, decreasing…
johngraham
  • 6,461
  • 2
  • 16
  • 22
17
votes
4 answers

Add .so and .a libraries to Makefile

I have a makefile which looks like this . DEFINES=-std=c++0x INCS_GTK=-I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gtk-2.0/gdk -I/usr/include/pango-1.0…
rajat
  • 3,415
  • 15
  • 56
  • 90
17
votes
2 answers

Embed libclang in an iOS app

I need to use libclang in an iOS app (for diagnostics and syntax highlighting) but I can't seem to figure out how to build it as is, let alone for iOS. Using CMake I generated an Xcode project for LLVM, but Xcode ran out of memory and disk space for…
Josh The Geek
  • 1,203
  • 12
  • 24
17
votes
2 answers

iOS Static Library Debug Symbols not being in included in dSYM

I'm working on a series of iOS apps which will share a common codebase. I've developed the common codebase as a static library and want it's debug symbols included in the primary app's .dSYM file. My understanding is that this is possible, but I…
jmac
  • 1,129
  • 14
  • 28
16
votes
2 answers

How to create static library from an existing framework in iOS?

I have been provided with a framework by a third party vendor for an iPhone hardware accessory. So I have a folder like Device.framework. Inside that folder is a binary file and a set of .h files. There are instructions for how to add this to an iOS…
16
votes
6 answers

How can I resolve "error LNK2019: unresolved external symbol"?

I've got this MFC application I'm working on that needs to have an embedded database. So I went hunting for a slick, fast "embeddable" database for it and stumbled accross SQLite. I created a DB with it, and I created a static library project with…
Attilah
  • 17,632
  • 38
  • 139
  • 202
16
votes
1 answer

"unrecognized selector sent to instance" to a static library despite ObjC flag

I'm getting a runtime error in my application: 2011-05-17 09:42:31.124 rxsync[67464:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSMutableURLRequest…
Steven Fisher
  • 44,462
  • 20
  • 138
  • 192
16
votes
3 answers

Linker Trouble: How to determine where a "/DEFAULTLIB" is coming from

I am trying to find a good way to determine what module at link time is causing a certain library to get processed as a "/DEFAULTLIB" as seen in the verbose linker output from Visual Studio. Here is my situation, I have several static library…
insipid
  • 3,238
  • 3
  • 26
  • 38
16
votes
3 answers

Required Framework vs Static Library

Building Modern Frameworks says every app has its own copy of a custom framework. Now that Xcode supports iOS frameworks, is it still true that frameworks are static libraries but just more convenient? If that's true, then why choose the static…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
16
votes
4 answers

Creating static library for iPhone

There's an open source library that I would like to use for my iPhone app. The library is written in C and compiles with Makefiles. I would like to use a static library. If I add the .a file to my project dependencies, it works well with the…
Martin Cote
  • 28,864
  • 15
  • 75
  • 99
16
votes
2 answers

ctypes for static libraries?

I'm attempting to write a Python wrapper for poker-eval, a c static library. All the documentation I can find on ctypes indicates that it works on shared/dynamic libraries. Is there a ctypes for static libraries? I know about cython, but should I…
MikeRand
  • 4,788
  • 9
  • 41
  • 70