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

Code signing a static library for iOS

I have been looking into code signing in iOS, but there are still some things unclear to me. We have built a static library and we want to be able to ship it to customers soon. However, we need to be sure we're following the right code signing…
sasfour
  • 399
  • 1
  • 3
  • 10
2
votes
2 answers

Creating a C++ static lib to use with Java on Android

I have some C++ code that I want to make into a static lib for use with Java on the Android platform. Can anyone point me to a resource that tells me how to do this? I am completely new to Java and Android.
Josh
  • 21
  • 2
2
votes
2 answers

How to build a C library for iOS by Xcode 6?

I trying to build C library for iOS like the following picture. I have build the liblib.a , but it compile error after I use liblib.a The error log is like the following when I use liblib.a file was built for archive which is not the architecture…
Martin
  • 2,813
  • 11
  • 43
  • 66
2
votes
0 answers

Visual Studio static library linking. Will unused functions or classes get optimized away?

Is there such an option for visual studio to optimize away code which isn't used at any point within code? For example if I have function int foo(bar b) in my static library, but the executable I link it into does not use that function. Will that…
2
votes
1 answer

Unsatisfied link for .so.12 file in android shared library

I am building libexif for Android. I am using the following cross compile script: PLATFORM_PREFIX=/home/tishu/Documents/osx-wks/GC/Thdl/jni/libexif-0.6.21/arch-arm/ NDK_PATH=/home/tishu/Documents/android-ndk-r8e/ NDK_PLATFORM=android-14 rmdir…
tishu
  • 998
  • 15
  • 29
2
votes
1 answer

Removing source code directory after compiling libraries

I have downloaded the source code from git for some third-party libraries, which contains a makefile, and so I have run make to compile the libraries. During compilation, this seems to add various libraries to directories such as /usr/bin. My…
Karnivaurus
  • 22,823
  • 57
  • 147
  • 247
2
votes
1 answer

w64-Mingw LLVMSupport.a : undefined reference to __imp_*

Quite weird bug trying to link something to LLVMSupport : C:/projects/builds/LLVM-3.3/lib/../lib/libLLVMsupport.a(Signals.cpp.obj):Signals.cpp:(.text+0x524): undefined reference to…
hl037_
  • 3,520
  • 1
  • 27
  • 58
2
votes
3 answers

Adding libraries to project

I'm new to Qt, and got following error to my C++ project: fatal error: apr_pools.h: No such file or directory I installed apr from https://apr.apache.org/compiling_unix.html and compiled it by executing: ./configure make make install But I…
Starspire
  • 272
  • 3
  • 15
2
votes
0 answers

Category in a private header in Static Library not found by Swift app code

I am trying redo an objective C app in Swift, Both the Swift app and Objective C app will use the same static library which is written in Objective C. I have a category inside a private header in the static library. The objective C app has no…
2
votes
1 answer

Importing Static library in to Android Project

I have a static library(libnative.a) which I have generated for arm architecture. Now I want to use the library in my android application using NDK. My Android.mk has LOCAL_STATIC_LIBRARIES := libnative i was also trying to load the library in…
Kishore
  • 952
  • 2
  • 11
  • 31
2
votes
1 answer

Mingw and Eclipse unable to find library - 2

I am faced with the exact same situation as the question raised by Gustavo in the following Link. Also, I have tried all the solutions posted in that link and other tags (such as changing library names from opus.a to libopus.a, change '\' to '/' and…
JagPK
  • 148
  • 1
  • 9
2
votes
1 answer

Static library test using XCTestCase

I am creating object of ISession class which gives me singleton instance, when object is allocated and initialized it pickup values from plist file, I am getting nil on [[NSBundle mainBundle] pathForResource:@"Manifest" ofType:@"plist"] so that…
Abbas Mulani
  • 703
  • 2
  • 8
  • 19
2
votes
0 answers

libtool error with xcodebuild command

I am getting following error when try to build xcode project using xcodebuild command. I have written this script under build phase of project to build my library for different architecture. I am following this link to build universal library. I…
user1101733
  • 258
  • 2
  • 14
2
votes
1 answer

Why is it I can use C++ code in a library and call from a C program. How does that work?

I created a static library on Windows using Visual Studio 2008 with these two files: header file was a simple C API: #ifdef __cplusplus extern "C" { #endif void init(); void stop(); #ifdef __cplusplus } #endif Implementation however was…
Angus Comber
  • 9,316
  • 14
  • 59
  • 107
2
votes
3 answers

Code::Blocks + MinGW: minimize the size of a static library

I've tried passing -ffunction-sections -fdata-sections for the compiler, but that doesn't seem to have the desired effect. As far as I understand, I also have to pass -Wl,--gc-sections to the linker, but I'm not linking the files at this point. I…
Paul
  • 6,061
  • 6
  • 39
  • 70
1 2 3
99
100