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

Unit testing MVC Controller making calls to a static library calling external API

Good day, I am confused about unit testing the following: 1. MVC Controller: [HttpGet] public async Task DoExternalCallsAsync() { var model = new MyModel(); await…
agfc
  • 852
  • 1
  • 6
  • 13
2
votes
1 answer

Attaching a static library to an iphone/ipad application

which is the best approach to include a static library with into an application for iPhone or iPad? I could choose to compile the library supplying right platform and building a library file with the ar utility and then add as a framework to the…
Jack
  • 131,802
  • 30
  • 241
  • 343
2
votes
1 answer

Linking a static library in gfortran using preprocessor

I have a library file created in gfortran, how to link it to a host program that uses its procedures using preprocessor (without using the GUI method) For exemple in Intel Visual fortran this is done by: !DEC$ Objcomment lib: 'library.lib'
Syntax_ErrorX00
  • 213
  • 3
  • 7
2
votes
2 answers

Using static library in both App and Cocoa Touch Framework targets

I've created a new "Cocoa Touch Framework" target called MyAppCore in my iPad project called MyApp, with the intention of putting some common code in there. Overall it works great, however, I've encountered problems with adding the static library…
2
votes
1 answer

Including other frameworks in an own framework

I am building a framework using the tutorial described in here. My framework uses some third party frameworks. When I am using this framework in a demo project, I get linker errors that symbols cannot be found for architecture etc. Probably the…
user-123
  • 874
  • 1
  • 13
  • 34
2
votes
1 answer

Error building OpenCV static libraries in Windows 8 with TDM-GCC-64, Cmake, and CodeBlocks

I am trying to build static libraries with the hopes of creating a portable executable. I was successful at building dynamic libraries using the following…
Langleson
  • 103
  • 1
  • 13
2
votes
3 answers

Is there a way to create C library with Cargo?

I need to create a (static) C library that binds to existing crate. Is there any way Cargo can create this C library for me? I have a crate (e.g. html5ever), and I want Cargo to create a C library based on C-API for that crate.
Daniel Fath
  • 16,453
  • 7
  • 47
  • 82
2
votes
1 answer

Unable to link the output (static library) of an external git CMake project to a CMake project

I'm having trouble trying to link a library that I recently pushed onto Git to my CMake project. I have named the library octal (GitHub) and am trying to link it to my other library bulletframe (GitHub). Both projects are created by me. I…
octopod
  • 824
  • 2
  • 10
  • 23
2
votes
2 answers

iPhone static libraries: How to hide instance variable

I'm creating a static library to share using the following guide: http://www.amateurinmotion.com/articles/2009/02/08/creating-a-static-library-for-iphone.html In one of the functions, I return a "SomeUIView" which is a subclass of UIView and is…
2
votes
0 answers

Using .a libraries with Android Studio

I downloaded and build the libraries from pjSIP for Android. It generated some static libraries (.a-files, 19 of them, to be precise), and I implemented them in my project, following this answer. My project structure looks like this…
Tristus
  • 183
  • 1
  • 2
  • 15
2
votes
0 answers

Android-NDK: incompatible target while linking ZeroMQ static library into a shared library

I have successfully compiled multiple static libraries with the ndk toolchain and linked them into my own project. I have to use many cpp files and they need protocol buffers and a ZeroMQ, as a library, to compile successfully. Linking against…
2
votes
1 answer

Undefined symbols when depending on a statically compiled library from VS2010

I have a project in Visual Stuio 2012 Express and I would like to include a static library, compiled with gcc from MinGW. I included the library i nthe project options of the project. Not working. Next I tried with a mockup minimal…
Vorac
  • 8,726
  • 11
  • 58
  • 101
2
votes
1 answer

Runtime Mismatch in Visual Studio 2012

I have a solution that was originally a VS2008 one, I have migrated it to VS2012 and that didn't create a problem. My solution uses DCMTK static libraries so I compiled them also using VS 2012. In total there are 68 projects in the solution of which…
2
votes
1 answer

XCode linking static library (GLEW) attempts dylib load

I am trying to link the GLEW library to an Xcode project, but I have been running into an issue. Whenever I set up my build to link with libGLEW.a, I will immediately get a crash on startup, with an error output reading: yld: Library not loaded:…
jujumbura
  • 425
  • 3
  • 9
2
votes
0 answers

Linking to Library Project in Xcode 6 not working

Alright, so I've been trying this for several hours, and I've read page after page after page after page and done everything they say, but I can't quite seem to get this to work. I'm trying to develop a centralized collection of classes and methods…
Nerrolken
  • 1,975
  • 3
  • 24
  • 53