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

Static Library with extern #define and typedef struct

I am trying to make a static library, where certain aspects of the library can be defined externally (outside the compiled library code). For function definitions, I can compile the library without issue using extern void foo() declarations in the…
John
  • 55
  • 6
2
votes
1 answer

iOS Integrate push notification in library

I am developing a static library with some common classes which can be used in multiple applications. This common code performs certain action on receiving Push Notification. Can I add push notification module (registering for push,receiving push…
2
votes
1 answer

How to remove static library from source control?

I followed this guide:http://www.raywenderlich.com/41377/creating-a-static-library-in-ios-tutorial to create a static library and added it as a subproject to my main project. When I tried to push after committing(Source Control->Push), I see my…
iamarnold
  • 705
  • 1
  • 8
  • 22
2
votes
1 answer

Creating and linking a static library to visual basic windows forms application

I have created two programs in Visual Studio2010. One is a visual basic windows forms application(user frontend) which prompts the user to select a file path (.bin file). The second program is a Visual Studio C++ Application, which has a ReadFile()…
Sandrocottus
  • 521
  • 3
  • 8
  • 31
2
votes
1 answer

Unable to add libpng library in my project

I am new to iPhone development and trying to load PNGs using libpng but unable to add it to my project after trying so much. I've got following errors while adding libpng to my project. Please help me how to get rid of these…
nomann
  • 2,257
  • 2
  • 21
  • 24
2
votes
1 answer

Library not found for -ljson11 but -lsqlite 3 is found

I'm trying to implement this tutorial with the addition that I want to include the json11 C++ library. I followed the same process for both, downloaded the repo from: https://github.com/libmx3/mx3, added them to the /deps/ folder of my project, and…
Mknsri
  • 87
  • 9
2
votes
1 answer

Xib file on static library

I'm taking over a project I did not start and I'm still a junior, so I need some help to clarify my mind. I'm developing a library for iOS 7.0 and up. This library is then distributed trough cocoapods. I've build a custom view and how I have a .xib…
Jack
  • 57
  • 6
2
votes
1 answer

Export function in c++ static library

My app links to a third party static library which without source code and I find that a function implemented in this library is exported in my exe using dumpbin.exe, just like a export function in a DLL. I have tried to modify the header file…
Cliffwolf
  • 85
  • 1
  • 10
2
votes
1 answer

Static library implementation

I am implementing a static library in C++. The problem I have is that in the header file that goes with the library other header files are included. How do I wrap the library so that these files are not visible? For example, say I have this…
user1523271
  • 1,005
  • 2
  • 13
  • 27
2
votes
1 answer

Qt static library doesn't output any files after build

I create a new project and select Library->C++ Library. then select Statically Linked Library and simply next other pages in wizard. After this when i try to build this new project, no output files (like .a) are produced. This is my .pro file…
Shnd
  • 1,846
  • 19
  • 35
2
votes
1 answer

Dynamic targets in Makefiles

I'm trying to create a Makefile that has a target per src/ subfolder so that it creates a static lib. I am currently trying this: %.o: %.cpp $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $< lib%.a: $(patsubst %.cpp, %.o, $(wildcard src/%/*.cpp)) …
Arkaitz Jimenez
  • 22,500
  • 11
  • 75
  • 105
2
votes
1 answer

To build the program with a static lib, libcurl.lib

I tried to build a stanalone program with a static lib, libcurl.lib. But I got bunch of errors. I ever refered to the related posts on stackoverflow and libcurl homepage, unfortunately it is in vain so far. The following is my building procedure and…
codexplorer
  • 541
  • 5
  • 21
2
votes
1 answer

How to resolve "undefined reference to " in NDK-built static library from NDK-built static library?

I'm getting an "undefined reference to 'myfunction' trying to call a function in a static (.a) library from a shared (.so) library. (This is an NDK question on OS X). The function is part of the fft library called "ffts-android" (ffts-android). …
2
votes
1 answer

Linker error with glew when library is statically linked

I am trying to build an opengl project in Visual Studio 2012. I wanted to statically include glew library, so I built it from source and copied the generated glew32sd.lib to my lib directory. I gave this lib path to Visual Studio and put…
ashutosh
  • 47
  • 1
  • 6
2
votes
2 answers

Library design methodology

I want to make the "TRAP AGENT" library. The trap agent library keeps the tracks of the various parameter of the client system. If the parameter of the client system changes above threshold then trap agent library at client side notifies to the…