当前位置:网站首页>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

边栏推荐
猜你喜欢

VCC(电源)和 GND(地)之间电容的作用

ZEMAX | 探究 OpticStudio 偏振分析功能

Oracle 注释详解(--、/**/、rem)
深度学习理论课程第八、九、十章总结

梯度下降、反向传播

芯片解密工作应该具备哪些条件?唯样商城

自监督论文阅读笔记 Self-supervised Learning in Remote Sensing: A Review

自监督论文阅读笔记 DetCo: Unsupervised Contrastive Learning for Object Detection

优雅的拦截TabLayout的点击事件

ZEMAX | 探索 OpticStudio中的序列模式
随机推荐
C# 数组之回溯法
Oracle count(1)、count(*)、count(列) 区别详解
神经网络基础
ZEMAX | 如何创建复杂的非序列物体
代码没写完,哪里有脸睡觉!17 张程序员壁纸推荐
【DC-5 Range Penetration】
自监督论文阅读笔记FIAD net: a Fast SAR ship detection network based on feature integration attention and self
Mysql 存储过程详解(procedure)
自监督论文阅读笔记: MoCoV2使用动量对比学习改进基线
php连接数据库脚本
c#,.net 下载文件 设置断点
Qlik Sense 字符串截取和拼接详解(Left、Right、&)
new / malloc / delete / free之间的区别
VCC(电源)和 GND(地)之间电容的作用
二阶段提问总结
采用Trench肖特基二极管,实现功率密度的显著提升
classpath:与classpath*的比较
滚动条 scrollbar 和scrollbar-thumb 样式
Qlik Sense 赋值详解(Set、Let)
ZEMAX | 如何使用ZOS-API创建自定义操作数