good_morning.hpp
#ifndef GOOD_MORNING_H #define GOOD_MORNING_H void good_morning(); #endif
good_morning.cpp
#include <iostream> #include "good_morning.hpp" void good_morning() { std::cout << "Good Monring!" << std::endl; }
main.cpp
#include "hello.hpp" #include "good_morning.hpp" int main(){ hello(); good_morning(); }
$ g++ -c hello.cpp good_morning.cpp
$ ar rvs libgreetings.a hello.o good_morning.o
ar: creating libgreetings.a
a – hello.o
a – good_morning.o
$ g++ main.cpp libgreetings.a
$ ./a.out
Hello!
Good Monring!