天天看点

c++静态库和动态库的添加

# 声明要求的 cmake 最低版本

cmake_minimum_required(VERSION 2.8)

# 声明一个 cmake 工程

project(helloSLAM)

# 设置编译模式

set( CMAKE_BUILD_TYPE "Debug" )

# 共享库

add_library(hello_shared SHARED libhelloslam.cpp)

# 语法:add_executable( 程序名 源代码文件 )

add_executable(helloSLAM uselibhello.cpp)

# 将库文件链接到可执行程序上

target_link_libraries(helloSLAM hello_shared)

转载于:https://www.cnblogs.com/shuimuqingyang/p/10197944.html