Next: , Up: Invoking libtool


4.1 Compile mode

For compile mode, mode-args is a compiler command to be used in creating a “standard” object file. These arguments should begin with the name of the C compiler, and contain the -c compiler flag so that only an object file is created.

Libtool determines the name of the output file by removing the directory component from the source file name, then substituting the source code suffix (e.g. ‘.c’ for C source code) with the library object suffix, ‘.lo’.

If shared libraries are being built, any necessary PIC generation flags are substituted into the compilation command.

The following components of mode-args are treated specially:

-o
Note that the -o option is now fully supported. It is emulated on the platforms that don't support it (by locking and moving the objects), so it is really easy to use libtool, just with minor modifications to your Makefiles. Typing for example
          libtool --mode=compile gcc -c foo/x.c -o foo/x.lo

will do what you expect.

Note, however, that, if the compiler does not support -c and -o, it is impossible to compile foo/x.c without overwriting an existing ./x.o. Therefore, if you do have a source file ./x.c, make sure you introduce dependencies in your Makefile to make sure ./x.o (or ./x.lo) is re-created after any sub-directory's x.lo:

          x.o x.lo: foo/x.lo bar/x.lo

This will also ensure that make won't try to use a temporarily corrupted x.o to create a program or library. It may cause needless recompilation on platforms that support -c and -o together, but it's the only way to make it safe for those that don't.

-no-suppress
If both PIC and non-PIC objects are being built, libtool will normally suppress the compiler output for the PIC object compilation to save showing very similar, if not identical duplicate output for each object. If the -no-suppress option is given in compile mode, libtool will show the compiler output for both objects.
-prefer-pic
Libtool will try to build only PIC objects.
-prefer-non-pic
Libtool will try to build only non-PIC objects.
-shared
Even if Libtool was configured with --enable-static, the object file Libtool builds will not be suitable for static linking. Libtool will signal an error if it was configured with --disable-shared, or if the host does not support shared libraries.
-static
Even if libtool was configured with --disable-static, the object file Libtool builds will be suitable for static linking.
-Wc,flag
-Xcompiler flag
Pass a flag directly to the compiler. With -Wc,, multiple flags may be separated by commas, whereas -Xcompiler passes through commas unchanged.