For using the library write the following commands in your terminal.
- Create an Object file for
MathLib.cpp
file
g++ -c MathLib.cpp -o MathLib.o
- Create an Archive file for
MathLib.o
file
ar rU MathLib.a MathLib.o
ranlib MathLib.a
- Use the library in code file named
test.cpp
g++ -Wall -o code test.cpp -L. MathLib.a
- Run the executable file
./code