The file is as follows:
[Email protected]:/home/test# ll Total thedrwxr-xr-x3Root root4096Sep2 Ten: -./drwxr-xr-x4Root root4096Sep2 ,: to.. /-rwxr-xr-x1Root root7901Sep2 Ten: theA. out*-rwxr-xr-x1Root root7901Sep2 Ten: -exe*drwxr-xr-x2Root root4096Sep2 Ten: -Lib/-rwxrwxrwx1Root root149Sep2 Ten:xxlibcaller.cpp*-rw-r--r--1Root root theSep2 the: *Libcaller.h-rw-r--r--1Root root1184Sep2 Ten: -LIBCALLER.O-rwxrwxrwx1Root root232Sep2 Ten: -libfuncapi.cpp*-rw-r--r--1Root root -Sep2 Ten: tolibfuncapi.h-rw-r--r--1Root root1196Sep2 Ten: -LIBFUNCAPI.O-rw-r--r--1Root root -Sep2 the: Aboutlibsystemapi.h-rwxrwxrwx1Root root theSep2 ,: -libsystem.cpp*-rw-r--r--1Root root1156Sep2 Ten: -LIBSYSTEM.O-rw-r--r--1Root root590Sep2 Ten: -Makefile-rwxrwxrwx1Root root theSep2 the:Panax Notoginsengtest.cpp*[email protected]:/home/test#
The contents of the document are as follows:
[Email protected]:/home/test# cat Test.cpp #include<iostream>extern voidcaller ();intMain () {caller (); return 0;} [Email protected]:/home/test# cat libcaller.h #ifndef lib_caller_h#defineLib_caller_hvoidcaller ();#endif[email protected]:/home/test# Cat Libcaller.cpp#include<stdio.h>#include"libfuncapi.h"voidcaller () {printf ("This is %s @%s:%d.", __function__,__file__,__line__); Func_api (); return;} [Email protected]:/home/test# cat Libfuncapi.h#ifndef func_api_h#defineFunc_api_hvoidFunc_api ();#endif[email protected]:/home/test# Cat Libfuncapi.cpp#include<stdio.h>#include"libsystemapi.h"#include"libfuncapi.h"voidFunc_api () {printf ("This is %s @%s:%d.\n", __function__,__file__,__line__); System_api (); return;}#if0intMain () {Funcapi (); return 0;}#endif[email protected]:/home/test# cat libsystemapi.h #ifndef system_api_h#defineSystem_api_hvoidSystem_api ();#endif[email protected]:/home/test# cat Libsystem.cpp #include<stdio.h>voidSystem_api () {printf ("This is %s @%s:%d.", __function__,__file__,__line__); return;} [Email protected]:/home/test#
Makefile
[Email protected]:/home/test# [email protected]:/home/test#CatMakefile Cur_dir=$ (PWD) RM=RM-Fobjs= $ (Cur_dir)/*. Olib_dir = $ (cur_dir)/liball:pre_work libsystemapi.a libfuncapi.a libcaller.a testlibsystemapi.a:g++-C Libs Ystem.cpp-o libsystem.o ar cr [email protected] LIBSYSTEM.OLIBFUNCAPI.A:LIBSYSTEM.O g++-C libfuncapi.cpp- o libfuncapi.o ar cr [email protected] LIBFUNCAPI.O $^LIBCALLER.A:LIBFUNCAPI.O libsystem.o g++-C libcaller. Cpp-o libcaller.o ar cr [email protected] libcaller.o $^test:post_work $ (lib_dir)/libcaller.a g++ TEST.CP P $ (lib_dir)/libcaller.a-o exepre_work:mkdir-p $ (lib_dir) post_work:mv./*.A $ (Lib_dir)/clean: $ (R M) $ (OBJS) $ (lib_dir)/*[email protected]:/home/test#
"Linux" Static Library compilation