【C 语言】动态库封装与设计 ( Windows 动态库简介 | Visual Studio 调用动态库 )

简介: 【C 语言】动态库封装与设计 ( Windows 动态库简介 | Visual Studio 调用动态库 )

文章目录

一、Windows 动态库简介

二、Visual Studio 调用动态库





一、Windows 动态库简介


在 C:\Windows\System32 目录中 , 存放着 Windows 中的动态库 ;


image.png


在 Visual Studio 项目中 , 选择 " 菜单栏 / 生成解决方案 " 选项 ,

image.png


在项目的根目录中 , 生成 Debug 目录 , 在目录下生成了如下文件 :

image.png



xxx.lib 是资源描述文件 , 用于描述 xxx.dll 动态库的 ;


xxx.dll 动态库 中包含了 函数的 二进制机器码 , 也就是 函数体 代码 ;



Windows 中 ( .dll 动态库 ) 与 Linux 中 ( .so 动态库 ) 动态库规范不同 ;






二、Visual Studio 调用动态库


拷贝动态库文件 : 将编译出的 xxx.lib 和 xxx.dll 文件 , 拷贝到 Visual Studio 工程的 源码目录 中 , 也就是与 主函数 源码所在目录 ; 此处 Hello.cpp 是主函数 ;

image.png



右键点击 " 解决方案资源管理器 " 中的解决方案 , 在弹出的菜单中 , 选择 " 属性 " 选项 ;


image.png


在 属性页 中 , 选择 " 链接器 / 输入 / 附加依赖项 " , 选择编辑 " 附加依赖项 " ;


image.png


输入 拷贝到源码路径的 xxx.lib 名称 , 目的是让编译器通过该 xxx.lib 文件查找对应的 xxx.dll 动态库文件 ;


image.png

目录
相关文章
|
IDE 关系型数据库 开发工具
使用Visual Basic进行Windows窗体开发
【4月更文挑战第27天】本文介绍了使用Visual Basic进行Windows窗体(WinForms)开发的步骤,从搭建开发环境到创建、设计用户界面,再到编写事件驱动的代码和数据绑定。Visual Basic结合WinForms提供了一种易学易用的桌面应用开发方案。通过调试、优化、部署和维护,开发者可以构建专业应用程序。随着技术发展,掌握最新UI设计和开发工具对于保持竞争力至关重要。本文为初学者提供了基础指导,鼓励进一步探索和学习。
450 0
|
5月前
|
NoSQL IDE MongoDB
Studio 3T 2025.11 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.11 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
296 3
|
2月前
|
NoSQL IDE MongoDB
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
172 1
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
3月前
|
安全 Linux C++
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
134 0
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
|
5月前
|
NoSQL IDE MongoDB
Studio 3T 2025.10 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.10 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
355 21
Studio 3T 2025.10 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
6月前
|
安全 Linux iOS开发
PVS‑Studio 7.36 for macOS, Linux & Windows - 代码质量安全静态分析
PVS‑Studio 7.36 for macOS, Linux & Windows - 代码质量安全静态分析
117 1
PVS‑Studio 7.36 for macOS, Linux & Windows - 代码质量安全静态分析
|
关系型数据库 数据库 C++
【C++】Windows使用Visual Studio C++链接云数据库PostgreSQL(沉浸式老爷教学)
【C++】Windows使用Visual Studio C++链接云数据库PostgreSQL(沉浸式老爷教学)
|
8月前
|
NoSQL IDE MongoDB
Studio 3T 2025.5 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.5 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
264 2
Studio 3T 2025.5 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
8月前
|
NoSQL IDE MongoDB
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
277 0
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
9月前
|
人工智能 C语言

热门文章

最新文章

下一篇
开通oss服务