CMakeLists.txt
cmake_minimum_required(VERSION 3.5) project(dll) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(SOURCE_FILES main.cpp dll.h dll.cpp) add_executable(dll ${SOURCE_FILES} dll.h dll.cpp)dll.h
#ifndef DLL_DLL_H #define DLL_DLL_H #endif #pragma once #include <iostream> void hello(void);dll.cpp
#include "dll.h" void hello(void) { std::cout<<"Hello from dll! "<<std::endl; }main.cpp
#include "dll.h" #include <iostream> using namespace std; int main() { hello(); return 0; }