// HelloLibrary.h
#ifndef __HELLO_LIBRARY__
#define __HELLO_LIBRARY__
#include <iostream>
using namespace std;
void HelloLibrary();
#endif
// HelloLibrary.cc
#include "HelloLibrary.h"
void HelloLibrary() {
cout << "HelloLibrary static" << endl;
}
// CMakeLists.txt
cmake_minimum_required(VERSION 3.23.2)
project(HelloLibrary)
# add_library(hello_library SHARED HelloLibrary.cc)
add_library(hello_library STATIC HelloLibrary.cc)
include_directories($(PROJECT_SOURCE_OIR))
add_executable(hello_main main.cc)
target_link_libraries(hello_main hello_library)
// main.cc
#include "HelloLibrary.h"
int main(int argc, char const *const argv[]) {
HelloLibrary();
return EXIT_SUCCESS;
}