Lesson 11

Dates: 6/25/2014
Application compilation and installation on Linux
Linux System Administration


Static libraries


  • A part of the code that can be compiled separately and linked with the other codes should be built as a library.



  • Building a static library
    gcc -c lib1.c
    gcc -c lib2.c
    gcc -c lib3.c
    ar -cru libextra.a lib1.o lib2.o lib3.o
    ranlib libextra.a
    
    to see the object files included in the library:
    ar -t libextra.a
    

  • Exercise
    Get the list of modules included in the Math library, libm.a:
    ar -t /usr/lib/x86_64-linux-gnu/libm.a
    
    Btw, file /usr/lib/x86_64-linux-gnu/libm.a is a part of package libc6-dev. If the file is missing on your computer, install package libc6-dev by using command apt-get install libc6-dev.


  • Take me to the Course Website