一、CMake3.29入门之四——动态链接库生成
一、准备
- 见CMake3.29入门二——静态链接库生成
- 只需更改Calculate.h Calculate.cpp CMakeList.txt
int Add(int iA, int iB);
extern "C" __attribute__((visibility("default"))) int Sub(int iA, int iB);
#include "Calculate.h"
int Add(int iA, int iB)
{
return iA + iB;
}
int Sub(int iA, int iB)
{
return iA - iB;
}
cmake_minimum_required(VERSION 3.29)
project(v2Shared)
set(CMAKE_CXX_STANDARD 11)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SRC_LIST)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
add_library(calc SHARED ${SRC_LIST})