( Creating object files

Info Catalog ( Using libtool ( Linking libraries
 3.1 Creating object files
 To create an object file from a source file, the compiler is invoked
 with the `-c' flag (and any other desired flags):
      burger$ gcc -g -O -c main.c
    The above compiler command produces an object file, `main.o', from
 the source file `main.c'.
    For most library systems, creating object files that become part of a
 static library is as simple as creating object files that are linked to
 form an executable:
      burger$ gcc -g -O -c foo.c
      burger$ gcc -g -O -c hello.c
    Shared libraries, however, may only be built from
 "position-independent code" (PIC).  So, special flags must be passed to
 the compiler to tell it to generate PIC rather than the standard
 position-dependent code.
    Since this is a library implementation detail, libtool hides the
 complexity of PIC compiler flags by using separate library object files
 (which end in `.lo' instead of `.o').  On systems without shared
 libraries (or without special PIC compiler flags), these library object
 files are identical to "standard" object files.
    To create library object files for `foo.c' and `hello.c', simply
 invoke libtool with the standard compilation command as arguments
 ( Compile mode):
      a23$ libtool gcc -g -O -c foo.c
      gcc -g -O -c foo.c
      echo timestamp > foo.lo
      a23$ libtool gcc -g -O -c hello.c
      gcc -g -O -c hello.c
      echo timestamp > hello.lo
    Note that libtool creates two files for each invocation.  The `.lo'
 file is a library object, which may be built into a shared library, and
 the `.o' file is a standard object file.  On `a23', the library objects
 are just timestamps, because only static libraries are supported.
    On shared library systems, libtool automatically inserts the PIC
 generation flags into the compilation command, so that the library
 object and the standard object differ:
      burger$ libtool gcc -g -O -c foo.c
      gcc -g -O -c -fPIC -DPIC foo.c
      mv -f foo.o foo.lo
      gcc -g -O -c foo.c >/dev/null 2>&1
      burger$ libtool gcc -g -O -c hello.c
      gcc -g -O -c -fPIC -DPIC hello.c
      mv -f hello.o hello.lo
      gcc -g -O -c hello.c >/dev/null 2>&1
    Notice that the second run of GCC has its output discarded.  This is
 done so that compiler warnings aren't annoyingly duplicated.
Info Catalog ( Using libtool ( Linking libraries
automatically generated byinfo2html