当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
三分钟看懂二极管的所有基础知识点
Phase Vocoder的补充完善,Matlab音频变速不变调、变调不变速
KASLR-内核地址空间布局随机化
观看华为AI技术领域课程--深度学习前三章总结
IPC 通信 - IPC
梯度下降、反向传播
卷积神经网络入门
MySQL 下载和安装详解
自监督论文阅读笔记DisCo: Remedy Self-supervised Learning on Lightweight Models with Distilled Contrastive
2021-04-30
微信小程序 自定义tabBar
西塞罗 论老年
神经网络基础
中空编码器的作用——唯样商城
new / malloc / delete / free之间的区别
全球一流医疗技术公司如何最大程度提高设计工作效率 | SOLIDWORKS 产品探索
Mysql 外键详解(Foreign Key)
【第三周】ResNet+ResNeXt
自监督论文阅读笔记 Incremental-DETR:Incremental Few-Shot Object Detection via Self-Supervised Learning
深度学习理论课程第四、五章总结