File list:
Code Files
/* The following code is saved to Plus.cpp *
/int my_plus (int x,int y)
{return
x + y;
}
/* The following code is saved to minus.cpp
/int my_minus (int x,int y)
{return
xy;
}
/* The following code is saved to MY_MATH.H *
/int my_plus (int x,int y);
int my_minus (int x,int y);
/* The following code is saved to Lib_test.cpp * * *
#include "my_math.h"
#include <stdio.h>
int main ()
{
printf ("[My_plus] =%d\n", My_plus (3,5));
printf ("[My_minus] =%d\n", My_minus (3,5));
return 0;
}
Makefile File
/* The following content is saved to Lib.mak * *
SHELL =/bin/sh
CC = g++
ar = ar
cflag =-o2-w-wall
= i.
Lib_target =./libmath.a
plus_obj = plus.o plus_src =./plus.cpp min_obj
= minus.o
min_src =./minus.cpp All
: $ (lib_target)
$ (plus_obj): $ (PLUS_SRC) $ (
CC) $ (cflag) $ (include_path)-C $ (PLUS_SRC)
$ (MIN _obj): $ (MIN_SRC) $ (
CC) $ (cflag) $ (include_path)-C $ (MIN_SRC)
$ (lib_target): $ (plus_obj) $ (min_obj) c17/>$ (AR) CQ $@ $^
rm-f $ (plus_obj)
rm-f $ (min_obj) Clean
:
rm-f $ (plus_obj)
rm-f $ (lib_targ BTN
/* The following content is saved to App.mak/
SHELL =/bin/sh
CC = g++
include_path =-I.
Test_target =./test
test_src =./lib_test.cpp
ldflags: =./libmath.a all
:
$ (CC)-G $ (TEST_SRC) $ ( Ldflags)-O $ (test_target) $ (include_path) Clean
:
rm-f $ (test_target)
Compiling Connections
Compile build Static library :
Use commands on Linux terminals:
Make-flib.mak
The effect of the following figure
compiling the build executable file
To use the command:
Make-fapp.mak
The effect of the following figure
Run: