【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

目录
相关文章
|
4月前
|
NoSQL IDE MongoDB
Studio 3T 2025.11 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.11 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
226 3
|
10天前
|
NoSQL IDE MongoDB
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
75 1
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
2月前
|
安全 Linux C++
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
108 0
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
|
4月前
|
NoSQL IDE MongoDB
Studio 3T 2025.10 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.10 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
291 21
Studio 3T 2025.10 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
5月前
|
安全 Linux iOS开发
PVS‑Studio 7.36 for macOS, Linux & Windows - 代码质量安全静态分析
PVS‑Studio 7.36 for macOS, Linux & Windows - 代码质量安全静态分析
94 1
PVS‑Studio 7.36 for macOS, Linux & Windows - 代码质量安全静态分析
|
7月前
|
NoSQL IDE MongoDB
Studio 3T 2025.5 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.5 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
238 2
Studio 3T 2025.5 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
7月前
|
NoSQL IDE MongoDB
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
234 0
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
8月前
|
人工智能 C语言
|
C++ Python Windows
在Visual Studio中使用Python(Windows)
在Visual Studio中使用Python(Windows)
115 2
|
11月前
|
存储 数据建模 程序员
C 语言结构体 —— 数据封装的利器
C语言结构体是一种用户自定义的数据类型,用于将不同类型的数据组合在一起,形成一个整体。它支持数据封装,便于管理和传递复杂数据,是程序设计中的重要工具。

热门文章

最新文章