I'm currently trying to port a C application to AIX and am getting confused. What are .a and .so files and how are they used when building/running an application?
5 Answers
Archive libraries (.a) are statically linked i.e when you compile your program with -c option in gcc. So, if there's any change in library, you need to compile and build your code again.
The advantage of .so (shared object) over .a library is that they are linked during the runtime i.e. after creation of your .o file -o option in gcc. So, if there's any change in .so file, you don't need to recompile your main program. But make sure that your main program is linked to the new .so file with ln command.
This will help you to build the .so files. http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html
-
3
.a are static libraries. If you use code stored inside them, it's taken from them and embedded into your own binary. In Visual Studio, these would be .lib files.
.so are dynamic libraries. If you use code stored inside them, it's not taken and embedded into your own binary. Instead it's just referenced, so the binary will depend on them and the code from the so file is added/loaded at runtime. In Visual Studio/Windows these would be .dll files (with small .lib files containing linking information).
-
1
-
1@Ancee: look at this question: stackoverflow.com/questions/205059/is-there-a-c-decompiler Mar 14, 2018 at 21:34
-
3
-
". Instead it's just referenced", how does this work - doesn't the code in the dynamic library have to be loaded into the hosting process? Oct 20, 2021 at 12:34
-
.a files are usually libraries which get statically linked (or more accurately archives), and
.so are dynamically linked libraries.
To do a port you will need the source code that was compiled to make them, or equivalent files on your AIX machine.
-
-
There are many excellent references for building both types of libraries and linking to them on the web. Google is your friend. Mar 21, 2012 at 17:06
-
1@Dunc - There are a couple of ways. Do you have a makefile? Usually the command that assembles the whole program (and hence calls the linker) will specify the places to look for library files with -L/dir/dir1/.../ and may also name libraries explicitly with -lname. You will find that the actual name is libname.a or libname.so. The linker can then figure out what to do if this is a reasonably normal program. But you still have the problem of making or finding the .so file. Have you got source code to build it, or an AIX library?– gbulmerMar 21, 2012 at 17:08
They are used in the linking stage. .a
files are statically linked, and .so
files are sort-of linked, so that the library is needed whenever you run the exe.
You can find where they are stored by looking at any of the lib directories... /usr/lib
and /lib
have most of them, and there is also the LIBRARY_PATH
environment variable.
Wikipedia is a decent source for this info.
To learn about static library files like .a read Static libarary
To learn about shared library files like .so read Library_(computing)#Shared_libraries On this page, there is also useful info in the File naming section.
a
rchive and other iss
haredo
bject