# 聲明要求的 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