Aquacolor

Aquacolor



【cmake学习(2)】链接动态库

Gumdrop · 2024-10-29 · 64浏览 · 未分类


文章目录
#

链接动态库

  • 动态库源文件编写

  • add_libraries(库名 SHARED 源文件)

  • add_executable(可执行文件名 源文件)

  • 链接库到可执行文件,target_link_libraries(可执行文件名 库名)

脚本语言有顺序需求,如果在link前没有两个目标文件被创建,cmake的编译将出错。(即cmake .出错。)

.
├── CMakeLists.txt
├── build
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   ├── Makefile
│   ├── cmake_install.cmake
│   ├── compile_commands.json
│   ├── hello.exe
│   ├── libmymath.dll
│   └── libmymath.dll.a
├── main.cpp
├── mymath.cpp
└── mymath.hpp

附件:

cmake+dll+ANSI转义.zip

参考文献: [1]【技能分享】为C语言控制台终端启用彩色支持(无需第三方软件) [2]Step 2: Adding a Library — CMake 3.31.0-rc2 Documentation



©

comment 评论区

添加新评论

face表情



  • ©2026 bilibili.com

textsms
内容不能为空
昵称不能为空
email
邮件地址格式错误
web
beach_access
验证码不能为空
keyboard发表评论


star_outline 咱快来抢个沙发吧!




©2026 Aquacolor

Theme Romanticism2.2 by Akashi
Powered by Typecho