When compiling on the Linux platform, often encounter the problem of the target library, there are static libraries and dynamic libraries, a single understanding is not too difficult, but for complex Engineering, once mixed together, the understanding and call of the entire project will cause a lot of trouble, this article summarizes the differences between these common compilation results files.
1, format description
Under linux compilation, often encounter suffixes: .o.so.a.la.ko and other format files, although linux does not use the extension as the identification file The only basis for the format, but the specification convention is still there, as follows: ◾.o is the target object file, equivalent to the .obj file in windows a.a is a static library, which can be one or more .o together The shared library generated by lib.la for static connections is actually a configuration document. You can view the *.la file with $file *.la or use vi to view it. ◾.so is a shared library, similar to the windows platform dll file
Addition: There is also a .ko file extension, but it is a dynamic link file suffix used by the Linux kernel, belonging to the module file, used in The kernel module is loaded when the Linux system starts.
Second, create an instance
1, create a .o object file
$gcc -c test.c
generate test.o, skip the link Object, so it is not an executable file.
2. Create a .a static library file
$ ar -r libtest.a test1.o test2.o
3, create a dynamic library.so
$ gcc -Wall -fpic -shared test1.c test2.c -o libtest.so
Execution of the previous sentence, compile test1.c and test2.c to generate dynamic library file libtest.so
4, link library file
$gcc -Wall -fpic -shared -Ltest test3.c -o libtest.so
Compile test3.c and link with static libtest.a (The default is to find the file under /usr/lib) to generate the libtest.so dynamic library.
5, generate .la library
.la library is generally done through the makefile, of course, can also be through the command line, reference command:
$libtool --mode=link Gcc -o libmylib.la -rpath /usr/lib –L/usr/lib –la
libtool will search for the libmylib.a file and pass it to libmylib.la. More libtool help is as follows: Tst@Tst-PC /cygdrive/d/$ libtool --helpUsage: libtool [OPTION]... [MODE-ARG]...
Provide generalized library-building support services .
--config show all configuration variables--debug enable verbose shell tracing-n, --dry-run display commands without modifying any files--features display basic configuration information and exit--mode=MODE use Operation mode MODE--preserve-dup-deps don't remove duplicate dependency libraries--quiet, --silent don't print informational messages--no-quiet, --no-silentprint informational messages (default)--tag= TAG use configuration variables from tag TAG-v, --verbose print more informational messages than default--no-verbose don't print the extra informational messages--version print version information-h, --help, --help-all Print short, long, or detailed help message
MODE must be one of the following:
clean remove files from the build directorycompile compile a source file into a libtool objectexecute au Tomatically set library path, then run a programfinish complete the installation of libtool librariesinstall install libraries or executableslink create a library or an executableuninstall remove libraries from an installed directory
MODE-ARGS vary depending on the MODE. When passed as first Option,`--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.Try `libtool --help --mode=MODE' for a more detailed description of MODE.
When Reporting a bug, please describe a test case to reproduce it and include the following information:
host-triplet: i686-pc-cygwinshell: /bin/shcompiler: gcccompiler flags: -g -O2 -pipelinker: /usr /i686-pc-cygwin/bin/ld.exe (gnu? yes)libtool: (GNU libtool) 2.4automake: automake (GNU automake) 1.11.1autoconf: autoconf (GNU Autoconf) 2.68
Report bugs to <[email protected]>.GNU libtool home page: <http://www.gnu.org/software/libtool/>.General help using GNU software: http://www.gnu.org /gethelp/.
Use httpry to sniff HTTP traffic under Linux Tutorial Sometimes you want to sniff HTTP traffic for
First install CentOS6 to install rp-pppoe this software, the previous version of centos is installed
Under Linux is a regular software installation method in addition to binary form of software distrib
First talk about my environment: redhat5.4 system, IP address is 192.168.0.10 Debian is 6.0 system,
Understanding of several address parameters involved in uBoot and Linux kernel
The method of teaching you whether to judge whether the Linux system is hacked is
Eight solutions for Linux hard disk problems
20 years of glory, forensic growth of SUSE and Linux
How to modify CentOS yum source
Solve Linux system driver synchronization and mutual exclusion
TNS-12555: TNS:permission denied error resolution
Linux View Port Status and Close Port Method
Linux root password cracking summary Daquan
Win7 how to customize the "Start" menu DIY "Start" menu graphic tutorial
How to set up a blank password remote login for Win7 system?
How to achieve fast booting of the computer
How to modify the word direction? Word text direction change tutorial
winXP remote control technology summary
Win8 system blue screen failure 0x00000050 error code phenomenon solution detailed
Linux operating system three ways to configure environment variables
Twemproxy installation and configuration
Win10 system can not run Tencent battle game platform solution
Win7 IIS 7 installation configuration and file graphic tutorial