To make a .a library file:
Originally Posted by str800
To make a .so shared object file:
ar ruvs libmylibrary.a *.o
ld -shared -o libmylibrary.so *.o
You mean .a, not .ar. A .so is a shared object file which contains relocation information needed by the dynamic linker. All intra-library dependencies are pre-resolved and the code is packaged into a single object. Usually, when compiling code that will become a .so, you should use the -fPIC option of the gcc compiler to generate "position independent code."
files, what is the difference between those?
A .a is just an archive of .o file (like tar, but not quite) which contains an index of symbol names to accelerate linking against the .o files in the archive. There is no need for -fPIC in this case.