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

How to package statically loaded JNI libraries?

I've currently got a Java application that is dynamically loading in a native library on two different platforms, Windows and Linux. I have the same library built targeting these two systems, a library.dll and a liblibrary.so. I've got to send this…
2
votes
0 answers

Setting VCTargetsPath to multiple directories

So, I've been trying to generate cocos2d-x static libraries, and I ran cmd as admin, and entered cocos gen-libs After about ten minutes, I got an issue about cpp windows props. I found out through here that I was supposed to set the VCTargetsPath…
Tespy
  • 971
  • 2
  • 9
  • 18
2
votes
1 answer

restbed static lib with examples

Hi i wanted to compile restbed as a static lib with examples but I have a linker error. using : ubuntu 16.04 gcc-5.4 What i did: cd dependency/openssl ./config *long text* Configured for linux-x86_64. *** Because of configuration changes, you…
rinn2883
  • 366
  • 1
  • 14
2
votes
1 answer

How to configuring NTL library in Visual Studio 2017

I have just installed Visual Studio 2017 and I want to use the NTL library. I have followed the steps described here (for VS2013). Compiling NTL library in Visual Studio 2013 As expected, it compiles (with several, I hope, negligible…
mir0soft
  • 73
  • 1
  • 1
  • 8
2
votes
1 answer

iOS: App size after adding C++ static library is too big?

I'm making a game using some C++ static libraries (.a files). After building completed, i see Xcode copies these libraries to the build folder (DerivedData) and some of them have size = 600mb (libcocos2d iOS.a - cocos2d-x) So i wonder what my app…
TomSawyer
  • 3,711
  • 6
  • 44
  • 79
2
votes
2 answers

Linking an archive to an archive

With GCC on Linux, is it possible to link a .a into another .a and then only link the resultant .a to my application? Or must my application know of the dependence between one archive and another and link them both? My understanding is that I must…
Joe
  • 7,378
  • 4
  • 37
  • 54
2
votes
0 answers

xcode iOS CreateUniversalBinary failed: file too large to create as a fat file

I recently add quite a lot of code to my iOS static library project. I always create universal binary that support all platforms (from iPhone4S to the current iPhone7) but after addition of the codes (which increase the .a size) results in:…
Zennichimaro
  • 5,236
  • 6
  • 54
  • 78
2
votes
1 answer

A lot of undefined reference errors using opencv static-libraries in eclipse c++ linux

I am working in a c++ project using opencv libraries. I need them static, so after download them I built my program, but the output was a large number of undefined references. A part of it is the next lines: …
Antonio
  • 23
  • 7
2
votes
3 answers

Using TagLib in Visual Studio 2010

EDIT: Yes, I have looked at this post. Unfortunately, it looks like the user ends up using MingW in the end. I am on Windows 7, 64-bit. I downloaded the most recent version of the TagLib code from the SVN repository. I am using revision 1202935. I…
2
votes
1 answer

Statically linked executable with LTO (link time optimization) : how to make it with previously built libraries

On Ubuntu with g++4.9, I have built a static library (call it libZeroMQ.a) following its instructions, and it was built without "-flto" (link time optimization). Now I am working on a project (call it MyEXE) which uses libZeroMQ.a, and I'll…
2
votes
0 answers

Create static library in Xcode for different architectures

I have an .h and .cpp file for iOS (ARMv8-a) and another .h and .cpp file for iPhone simulator (x86_64). I need to include them in an Xcode project. How should I do that? Do I need to create another project/target for those files? Thanks
Juan Herrero Diaz
  • 833
  • 1
  • 7
  • 17
2
votes
2 answers

How to cross-compile D-Bus to ARM?

I want to cross-compile D-bus to arm. Toolchain: arm-linux-gcc-3.4.1 configure option: CC=arm-linux-gcc ./configure --prefix=/opt/dbus/ --host=arm-linux --enable-abstract-sockets -with-xml=expat Source code: d-bus-1.2.24 d-bus-1.3.1…
Mandy
  • 405
  • 2
  • 6
  • 14
2
votes
1 answer

Fail to load static library bundle storyboard (not yet loaded) - iOS

I want to build a static library which include bundle with storyboard. When I create a sample project and import the bundle and .h file and run it, I get error as below: …
user831098
  • 1,803
  • 6
  • 27
  • 47
2
votes
2 answers

How do I add static and dynamic libraries in Ubuntu 16.04?

Basically, I downloaded an SDK for C/C++, and I have several .so and .a files. There is no install script with the SDK. It simply contains the headers and the .so and .a files. I don't really know where to put these files. Typically, if I download…
Ralff
  • 401
  • 2
  • 5
  • 15
2
votes
1 answer

RTKlib (C library) with QT (C++ code)

I'm try how to use RTKlib (All of the library functions and APIs were written in ANSI C (C89)). The library are organize like this: rtklib.h file1.c ... file1.c ... With QT (in ubuntu 32), I start a new…