`

Autoconf, Automake, Libtool & .so、.o、.lo、.a、.la后缀文件含义

 
阅读更多

.o : 编译的目标文件
.a : 静态库,其实就是把若干o文件打了个包
.so : 动态链接库(共享库)
.lo : 使用libtool编译出的目标文件,其实就是在o文件中添加了一些信息
.la : 使用libtool编译出的库文件,其实是个文本文件,记录同名动态库和静态库的相关信息

la只有在用libtool编译应用程序或库时才用,即开发者只指明la文件,至于最终链接a还是so由libtool决定,不使用libtool的小程序用不上la, lai是和la类似的文本文件;so是直接用特殊编译参数编译出来的。

4 Invoking libtool

The libtool program has the following synopsis:

libtool [option
]... [mode-arg
]...

and accepts the following options:

`--config'
Display libtool configuration variables and exit.
`--debug'
Dump a trace of shell script execution to standard output. This produces a lot of output, so you may wish to pipe it to more(1) or redirect to a file.
`-n'

`--dry-run'
Don't create, modify, or delete any files, just show what commands would be executed by libtool.
`--features'
Display basic configuration options. This provides a way for packages to determine whether shared or static libraries will be built.
`--finish'
Same as `--mode=finish' .
`--help'
Display a help message and exit. If `--mode=mode ' is specified, then detailed help for mode is displayed.
`--mode=mode '
Use mode as the operation mode. By default, the operation mode is inferred from the contents of mode-args . If mode is specified, it must be one of the following:
`compile'
Compile a source file into a libtool object.
`execute'
Automatically set the library path so that another program can use uninstalled libtool-generated programs or libraries.
`finish'
Complete the installation of libtool libraries on the system.
`install'
Install libraries or executables.
`link'
Create a library or an executable.
`uninstall'
Delete libraries or executables.
`--version'
Print libtool version information and exit.

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 C source code suffix `.c' with the library object suffix, `.lo' .

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

Note that the `-o' option is not supported for compile mode, because it cannot be implemented properly for all platforms. It is far easier just to change your Makefiles to create all the output files in the current working directory.

4.2 Link mode

`link' mode links together object files (including library objects) to form another library or to create an executable program.

mode-args consist of a command using the C compiler to create an output file (with the `-o' flag) from several object files.

The following components of mode-args are treated specially:

`-all-static'
If output-file is a program, then do not link it against any shared libraries at all. If output-file is a library, then only create a static library.
`-dlopen file '
Same as `-dlpreopen file ' , if native dlopening is not supported on the host platform (see section 9 Dlopened modules ). Otherwise, no effect.
`-dlpreopen file '
Link file into the output program, and add its symbols to dld_preloaded_symbols (see section 9.2 Dlpreopening ).
`-export-dynamic'
Allow symbols from output-file to be resolved with dlsym(3) (see section 9 Dlopened modules ).
`-Llibdir '
Search libdir for required libraries that have already been installed.
`-lname '
output-file requires the installed library `libname ' . This option is required even when output-file is not an executable.
`-no-undefined'
Declare that output-file does not depend on any other libraries. Some platforms cannot create shared libraries that depend on other libraries (see section 8 Inter-library dependencies ).
`-o output-file '
Create output-file from the specified objects and libraries.
`-release release '
Specify that the library was generated by release release of your package, so that users can easily tell which versions are newer than others. Be warned that no two releases of your package will be binary compatible if you use this flag. If you want binary compatibility, use the `-version-info' flag (see section 6 Library interface versions ).
`-rpath libdir '
If output-file is a library, it will eventually be installed in libdir .
`-static'
If output-file is a program, then do not link it against any uninstalled shared libtool libraries. If output-file is a library, then only create a static library.
`-version-info current [:revision [:age ]]'
If output-file is a libtool library, use interface version information current , revision , and age to build it (see section 6 Library interface versions ). Do not use this flag to specify package release information, rather see the `-release' flag.

If the output-file ends in `.la' , then a libtool library is created, which must be built only from library objects (`.lo' files). The `-rpath' option is required. In the current implementation, libtool libraries may not depend on other uninstalled libtool libraries (see section 8 Inter-library dependencies ).

If the output-file ends in `.a' , then a standard library is created using ar and possibly ranlib .

If output-file ends in `.o' or `.lo' , then a reloadable object file is created from the input files (generally using `ld -r' ). This method is often called partial linking .

Otherwise, an executable program is created.

4.3 Execute mode

For `execute' mode, the library path is automatically set, then a program is executed.

The first of the mode-args is treated as a program name, with the rest as arguments to that program.

The following components of mode-args are treated specially:

`-dlopen file '
Add the directory containing file to the library path.

This mode sets the library path environment variable according to any `-dlopen' flags.

If any of the args are libtool executable wrappers, then they are translated into the name of their corresponding uninstalled binary, and any of their required library directories are added to the library path.

4.4 Install mode

In `install' mode, libtool interprets mode-args as an installation command beginning with cp , or a BSD-compatible install program.

The rest of the mode-args are interpreted as arguments to that command.

The command is run, and any necessary unprivileged post-installation commands are also completed.

4.5 Finish mode

`finish' mode helps system administrators install libtool libraries so that they can be located and linked into user programs.

Each mode-arg is interpreted as the name of a library directory. Running this command may require superuser privileges, so the `--dry-run' option may be useful.

4.6 Uninstall mode

This mode deletes installed libraries (and other files).

The first mode-arg is the name of the program to use to delete files (typically `/bin/rm' ).

The remaining mode-args are either flags for the deletion program (beginning with a `-'), or the names of files to delete.

Reference and more:

www.linuxsir.org/bbs/printthread.php

angusag.spaces.live.com/

交叉编译中libtool相关的问题

www.delorie.com /gnu /docs /libtool /libtool_8.html

4 Invoking libtool

GNU Libtool index
http://developer.apple.com/documentation/DeveloperTools/glibtool/libtool_9.html

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics