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

Compile Static executable with CMAKE

I am trying to build static executable but having no success in building up. It was working fine before adding following lines: SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") SET(BUILD_SHARED_LIBRARIES OFF) SET(CMAKE_EXE_LINKER_FLAGS "-static") I want to…
aak
  • 107
  • 1
  • 4
  • 12
2
votes
1 answer

Separate sandbox for ios cocoa touch static library

I wanna create a static library that will do some security sensitive operations. It is important for me that the other applications that use my static library can not access data of the static library. Actually it is important that both data that I…
Husein Behboudi Rad
  • 5,434
  • 11
  • 57
  • 115
2
votes
3 answers

Is it possible to have Global Methods in C#

So I have a static class lets say its called Worker, and lets say I have a method inside it called Wait(float f) and its all public so I can acess it anywhere like so: Worker.Wait(1000); Now what I am wondering is there any way I can define some…
Bruno Filip
  • 139
  • 8
2
votes
1 answer

Packaging and distributing a QtRuby app as a gem? Or how?

I have finished developing a GUI desktop Ruby application that uses Qt through the qtbindings gem, and I need to release it with a few requirements: The user doesn't have to build or compile anything, especially Qt libraries, installing Ruby and…
amireh
  • 700
  • 4
  • 13
2
votes
1 answer

Linking libraries statically

I have to write a programm that should afterwards run on a supercomputer, so I got the hint I should link my libraries statically. The problem is when I link g++ -o calcrank -llinbox -lgivaro -lgmp -lntl -static -static-libstdc++ -static-libgcc…
Valentin
  • 167
  • 2
  • 10
2
votes
0 answers

Cannot use classes from static library

I need to import a library in iOS but I can't seem to figure out how. I have an .A file and an 'include' folder in my finder. the 'include' folder has a few .h files and nothing else. I cant seem to initialize the library, I've tried Build phases >…
jamian
  • 1,544
  • 2
  • 16
  • 25
2
votes
1 answer

MSVC project missing "__popcountdi2" when linking against GCC-built static library

I have a windows executable project that links against a static library (.lib) built with GCC 6 (MinGW). The following error occurs during compilation: LNK2019 unresolved external symbol __popcountdi2 referenced in function ... The symbol is linked…
MarkP
  • 4,168
  • 10
  • 43
  • 84
2
votes
0 answers

Does Xamarin.ios have better support for static libraries or dynamic frameworks?

I produce an SDK, which is written in a mixture of ObjC and C, and exposes an ObjC API to be used by third party apps. A customer would like to use this SDK in an iOS app that is written using Xamarin. The customer is not really familiar with…
JosephH
  • 37,173
  • 19
  • 130
  • 154
2
votes
1 answer

Undefined references in static OpenCV libraries

I have a project in C++ that uses OpenCV 3.1 and works fine using shared libaries. But now I want to compile it using static libraries (located in a folder within the project directory) because I want to be able to export it (and also edit and…
Leonardo Lanchas
  • 1,616
  • 1
  • 15
  • 37
2
votes
3 answers

How to build same library more than once in Yocto?

I have 2 application, both uses the same library but the library should be build with a flag enabled in one and disabled in other. this is a static library, so at run time there won't be a conflict in runtime. But the library is separate ie, the…
jsaji
  • 900
  • 1
  • 15
  • 31
2
votes
1 answer

libtool: convert/extract la to a

Is it possible to convert or maybe extract a file from .la library to .a? I've a project where I have my application linked statically against all libraries, but some of them are generated with libtool (.la libs), while others are created with gcc…
2
votes
1 answer

Using static libraries compiled C++ under vs80 (Visual Studio 2005) in a Visual Studio project compiling under c++ vs140 (Visual Studio 2015)

Is it possible to use a C++ static library (.lib) compiled using vs80 (Visual Studio 2005) in a Visual Studio 2015 c++ project (vs140)? In terms of similar questions, I found 'Can I use a Visual Studio 6 compiled C++ static library in Visual Studio…
2
votes
1 answer

"file not found " error while creating a static library in c using gcc - linux

I have a file hello.c #include void hello() { printf("Hello!\n"); } A header hello.h #ifndef _hello_ #define _hello_ void hello(); #endif main.c #include #include "hello.h" int main() { hello(); return 0; } I am…
Eternal Learner
  • 3,800
  • 13
  • 48
  • 78
2
votes
1 answer

Get dev library packages for arm on x64 Ubuntu host?

I am building a project that requires a number of libraries, for windows I got prebuilt libs from MSYS2, for linux from the ubuntu repos, and now I am porting to android, so I need the same libraries for armhf and arm64. The good news is the ubuntu…
dtech
  • 47,916
  • 17
  • 112
  • 190
2
votes
2 answers

Logback issue when importing jar

I imported a third-party library into my Java/Spring project (just importing, nothing from the library is used) and when I run the app I get: ERROR in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1aea858e - Missing integer token, that is %i, in…
asenovm
  • 6,397
  • 2
  • 41
  • 52