using c library in another c library, linux - c

Hi All
I wrote a static library (libA) that uses another library (libB).
How can I link libB to my libA in eclipse (linux)? i cannot find linkage options in project properties, they are not on there usual place.
Thx

Static libraries don't link. They are an archive of object files (.o files). These archives are then taken as arguments during a linking phase, have their object files extracted and linked into the application at that time. As such, static libraries cannot link against anything.

Related

How can I build standalone static library in c for a firmware module

How can I build a standalone static library (.a) for a firmware module and link that static library in the main project (without providing access to header files in that module) ?
I know about ar command but that is just compiling the .c files, when I try to use the functions in one of the .c files of the firmware module it shows me implicit function deceleration warning. I do not want to export the .h files but rather just provide a libexample.a package to the developer to use the firmware module.
Will the pre-compiled header work in this scenario?

Reason you can't statically link against a .so or .dll file?

.so and .dll files must properly export all public objects, because you can dynamically link against them.
Why is it that you cannot currently statically link against .so and .dll files? Are they missing some information required by the linking process, or has the ld code for it just not been written?

building & linking dynamic library of a .h (header) file in C on linux platform

I have to build a dynamic library of a header file using C on Linux platform.
and use it while building my executable.
How to build dynamic library of a header file?
We can not make shared library from header file please refer http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html for your reference

Is it possible to use SWIG to wrap static libraries with .a extension?

I compiled a C project using the NDK and got many .a files which as I understand, they are nothing else than static libraries. I don't know exactly what is the difference between .a and .so files but I wanted to ask: I know exactly that with a toolchain in NDK I can import all the .a files and get the .so file but having the .a files how to include the .a files in the .interface files to SWIG the whole library ?
SWIG does not generate interface files from libraries. You can provide a wrapper to include all relevant header (.h) files, or create the .i file manually, only exposing the relevant C functions.
Note that Android app cannot work with static libraries, you must build a dynamic library .so to use JNI. You will call System.load() from your Java code to load this .so from disk.

Static linking to lib and still requesting DLL

Using visual studio 2008, I have an .H and a .LIB file of a library.
I wrote a program and referenced the LIB via the project properties.
It compiles fine, but when it runs, it asks for the DLL to be installed.
If the DLL is in the same dir as the EXE it works but, if I have the LIB, doesn't it already mean the functions are statically linked to my program?
Not all lib files are static libraries. Some are import libraries, and chances are, that's what you linked with.
If your lib file is much smaller than its corresponding dll file, that's a sure sign that it's an import library.
Letting your program use a DLL requires an import library. It is a file with the .lib extension, just like a static .lib. But it is very small, it only contains a list of the functions that are exported by the DLL. The linker needs this so it can embed the name of the DLL in the import table. You can see this for yourself by running Dumpbin.exe /imports on your .exe

Resources