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

Static compiling using CMake- cannot find -lgtk-3

I'm trying to do a static compile of a C++ project using CMake, but it seems to still be linking dynamically. I'm new to CMake so I'm not entirely sure of how everything works. This is my project root directory's…
2
votes
2 answers

How to add a new filter to ffmpeg library

I am trying to add functionality to FFmpeg library. The issue is that in developer guide there are just general instruction on how to do it. I know that when I want to add something to ffmpeg I need to register the new functionality and rebuild the…
Croolman
  • 1,103
  • 13
  • 40
2
votes
0 answers

Static build of Qt - Plugin class name could not be determined for qwayland-egl plugin

$ /opt/Qt5.5/5.5-static/bin/qmake yyyy.pro Project WARNING: Plugin class name could not be determined for qwayland-egl plugin. Project WARNING: Plugin class name could not be determined for qwayland-generic plugin. I statically built Qt 5.5.1. I…
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
2
votes
0 answers

Do I need to include library dependencies again in my project for the .libs which are already included in the library I am statically linking with

I have a library file : Accept.lib, This file has two library dependencies: AcceptSalary.lib and AcceptDesignation.lib. I have one exe project: AcceptAndDisplay.exe, where I want to call method from : Accept.lib. Now for static…
2
votes
1 answer

c++: multiple copies of a static library in memory

I use a static library in the c++ program. Can memory stores multiple copies of the library? Or for one program, one copy of a static library?
amirassov
  • 81
  • 1
  • 5
2
votes
1 answer

Linking Libraries with NuGet Packages as dependencies in Visual Studio

I have a Console Project LinkExample that contains a main.cpp. #include int main() { WriteSomething(); return 0; } The LinkExample links a static Library Project named Library. Library.Lib is linked correctly. Library…
Johannes
  • 6,490
  • 10
  • 59
  • 108
2
votes
0 answers

Replace/Override statically linked library

I have an object file — foo.so — provided by a vendor. That object file was statically linked with a publicly available library — bar_1.0.a. There is a new version of the library bar_1.1.a that fixes a critical bug, but the vendor is not supplying a…
Sean Bright
  • 118,630
  • 17
  • 138
  • 146
2
votes
1 answer

Using precompiled headers with a static library project

I am in need of some advice on how to setup my project. I'm building a static library and want to know if the way I'm using precompiled headers is correct before I go too far. So far, my stdafx file is just including (for types like DWORD, etc.)…
Matthew
  • 24,703
  • 9
  • 76
  • 110
2
votes
0 answers

How to create distributable static libraries with which do not produce conflicts and export only selected symbols on Clang/CMake/iOS?

I have a C++ project with many libraries that is built with Clang using CMake. The purpose of this project is to compile library X which I distribute to clients along with its API headers. The API itself is completely 'isolated' and depends only on…
dreamzor
  • 5,795
  • 4
  • 41
  • 61
2
votes
0 answers

Using a third party library inside a framework

I am building an SDK which uses some third party library (for example, AFNetworking). As far as I know, if an app using my SDK also wants to use the same library, it will end up generating a compile error with duplicate symbols. What is the best way…
user-123
  • 874
  • 1
  • 13
  • 34
2
votes
0 answers

Hiding symbols while building static library in Visual Studio

I'm looking for a way to hide symbols in a static library built in Visual Studio. I've been able to do it in clang and gcc but I'm not sure if there's a way to do it in VS. I am building a static library parentlib that needs to be built on Linux…
Hosack
  • 1,597
  • 1
  • 8
  • 10
2
votes
3 answers

GCC keeps on showing "/usr/bin/ld: cannot find" even when -L path is specified

I am trying to compile main.c with a static library and header files on an Ubuntu server using gcc and ssh using Terminal on Mac. I uploaded the library file and specified it with -L option and specified the header files using the -I option. I tried…
Edenapple
  • 23
  • 1
  • 4
2
votes
1 answer

Wrap VC++ Static Library in a DLL to use with .Net Managed Assemblies

I have some source that can compile with MINGW gcc or with VC++ (but isn't in a VS project, it has a makefile that is read by nmake). I compile with nmake and it produces a static lib and I would like to compile the code as a DLL to use with my…
Jeff LaFay
  • 12,882
  • 13
  • 71
  • 101
2
votes
2 answers

Linking a program with two static libraries each containing functions that depend on functions in the other?

I'm actually trying to call a function a (stocked in liba.a) from another function b (stocked in libb.a) but I have a linkage error. There are my files: a.c #include void a() { printf("a\n"); } b.c void a(); void b() { …
2
votes
1 answer

iOS - static library framework size is very big opposed to dynamic embedded framework

I created a static library (framework) using the following tutorial https://github.com/jverkoey/iOS-Framework. The size of the framework is huge - about 220 MB. When I instead create a dynamic embedded framework , the size is only ~12MB. Important…
Avba
  • 14,822
  • 20
  • 92
  • 192