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

Is it safe to return C-style array from class that wraps a 3rd-party C++ object under ARC?

I am using a 3rd-party static library implemented in C++. I'm wrapping that object in a custom ObjC object in h and mm files, basically following the method described here. Many of the functions in the library return C-style arrays of ints or…
LarrySnyder610
  • 2,277
  • 12
  • 24
2
votes
2 answers

FILE IO to InMemory IO

I have a legacy C library which accepts a file, works on the file payload and writes the processed payload to an output file. The functions in the library are tightly coupled with FILE i.e. it passes around FILE handle to the functions and functions…
namith
  • 546
  • 1
  • 8
  • 18
2
votes
0 answers

Can't import static library header files

Hi My app storyboard works and I can link the custom class of my MainProject Storyboard to Static Library ViewController but my problem is when i try to use #import from my MainProject to locate for header files, my header files in my Static…
Ron Pelayo
  • 655
  • 2
  • 7
  • 22
2
votes
4 answers

Compile errors with C++ static library include in Swift project

I created a static library that includes the follow C++ files: //TestClass.h File: #ifndef TESTCLASS_H_ #define TESTCLASS_H_ using namespace std; #include class TestClass { public: TestClass(); virtual ~TestClass(); int sum(int…
Tatiana
  • 390
  • 8
  • 23
2
votes
1 answer

How do you define a static matrix with #define in C?

In the directive #define you can define a static array, but I couldn't understand how you can define a static matrix?. I would like to create a library of static matrices. Can anyone help me?
ginosal
  • 35
  • 1
  • 1
  • 6
2
votes
1 answer

How to make a C++ library for Python

I am new to object oriented programming and I am struggling to find a good tutorial on how to make a library in C++ that I can import into Python. At the moment I am just trying to make a simple example that adds two numbers. I am confused about…
turnip
  • 2,246
  • 5
  • 30
  • 58
2
votes
1 answer

Make static library for iOS with existing C code in Xcode

Short version of the question: So basically what I'm looking to do is to take an existing library written in C (https://github.com/lsalzman/enet) and turn it into a static library for iOS. I am just looking for an easy to understand step by step of…
2
votes
1 answer

Linking and LOADING static .lib with mex

So, I have a MEX gateway script file that calls my C source code. I've used the -L and -I commands to link my 64-bit compiled GSL libraries (.libs) to my mex executable, which is then compiled under the extension of .mexw64. I want for this…
user3145575
2
votes
1 answer

Call function in a static library without implementation

I'd like to know if it's possible, within a static library, call a function that the implementation is in my application instead of in the library. Like this: Static Library foo.h void foo_func(); foo.c #include "foo.h" void foo_func() { …
2
votes
1 answer

Find out whether a lib requires static or dynamic runtimes

Whenever you link static libraries into your Visual C++ project you have to make sure that the value for the runtime library of the project matches the value that was used to compile the library. If for example the library was compiled with the…
Compuholic
  • 388
  • 4
  • 14
2
votes
1 answer

Unresolved External Symbols in complex library dependent project using WINAPI

Having searched for days now i decided to post a question here and hope that somebody has the ultimate idea or advice. I wrote a WINAPI wrapping mechanism consisting of a WindowManager and a WINAPIWindow class. The latter uses the famous "First…
MABVT
  • 1,350
  • 10
  • 17
2
votes
1 answer

Cocoapods --no-integrate command for different targets

As per http://guides.cocoapods.org/terminal/commands.html#pod_install, if you want to integrate libs or external dependency at yourself you can use -no-integrate option. Basically i have my static library (comms.a) and header (comms.h). My…
harshit2811
  • 827
  • 1
  • 7
  • 21
2
votes
1 answer

Building PCL library statically

I am currently trying to collect data from a camera that only works with static libraries. Then I have to install PCL statically. Since there is no All-in-one kit as for the dynamic version, I have done it manually, with Cmake. The build succeeded,…
Hinkel
  • 23
  • 4
2
votes
1 answer

json-framework error in iPhone static library

I have an iPhone app that uses the json-framework. I moved some of the code, including the json-framework source, from the main project to a static library. When I did this, the json-framework stopped getting compiled into the binary (double checked…
David Beck
  • 10,099
  • 5
  • 51
  • 88
2
votes
0 answers

How to change the load order of libraries in qt

Im working on a opengl scenegraph for students. The scenegraph was created by someone else and we just want to hide it in libraries, to let the student focus on specific aspects. I have created two static libraries with qt and now i want to load…
Lycan
  • 29
  • 2
1 2 3
99
100