当前位置:网站首页>VS2022 encapsulation under Windows dynamic library and dynamic library calls
VS2022 encapsulation under Windows dynamic library and dynamic library calls
2022-08-03 06:10:00 【Shiyu】
First, create a new project MyLib (encapsulate your own dynamic library)
1. Header file Test.h: (_declspec(dllexport) should be placed in front of the exported class name, indicating that the package should be exported to the library)
#pragma onceclass _declspec(dllexport) Test{public:void say();};
2. Source file Test.cpp:
#include "Test.h"#includevoid Test::say() {std::cout << "Hello! My name is linyu!" << std::endl;}
3. Right-click on project properties -> configuration properties -> configuration type (modified to dynamic library.dll):
4. Right-click to generate, a dynamic library will be generated (two files will be generated, one is dll, the other is lib, lib is the index address information of the function entry, and the dll is the real implementation of the function)
Second, create a new project TestMyLib (call the library just packaged)
1. Copy the header file Test.h to the source file directory of the project
2. Go back to the project, header file -> right click -> add existing item Test.h
3. Copy the dynamic library file MyLib.dll to the directory where the exe is generated:
4. Linker->General->Additional library directory, link to the directory where MyLib.lib is located:
5. Linker->Input->Additional dependencies, add the generated library name MyLib.lib
6. Write the TestMyLib.cpp file:
#include #include "Test.h"int main(){Test t;t.say();}
7. Click to run
边栏推荐
猜你喜欢
随机推荐
西塞罗 论老年
MySQL 下载和安装详解
ZEMAX | 如何使用ZOS-API创建自定义操作数
servlet学习(七)ServletContext
三分钟看懂二极管的所有基础知识点
【第三周】ResNet+ResNeXt
芯片解密工作应该具备哪些条件?唯样商城
借助ginput函数在figure窗口实时读取、展示多条曲线的坐标值
自监督论文阅读笔记 Self-Supervised Visual Representation Learning with Semantic Grouping
ZEMAX | 如何使用渐晕系数
常见的电子元器件分类介绍
memblock
什么是参数化设计,通过实操了解一下? | SOLIDWORKS 操作视频
STM32启动文件的选择
ZEMAX | 如何围绕空间中的任何点旋转任何元素
Oracle 分区索引详解(local、global)
new / malloc / delete / free之间的区别
自监督论文阅读笔记FIAD net: a Fast SAR ship detection network based on feature integration attention and self
深度学习理论课程第八、九、十章总结
enum和enum class的区别