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

边栏推荐
- 二叉树常见的问题和解决思路
- 梯度下降、反向传播
- 动漫:海贼王女
- Kettle 从资源库中载入新的转换出错(Invalid byte 1 of 1-byte UTF-8 sequence)
- 自监督论文阅读笔记 TASK-RELATED SELF-SUPERVISED LEARNING FOR REMOTE SENSING IMAGE CHANGE DETECTION
- ZEMAX | 在 OpticStudio 中使用自由曲面进行设计
- 卷积神经网络入门
- 电子元器件的分类有哪些?
- SolidWorks 操作视频 | 流体分析结果演示
- 自监督论文阅读笔记 Self-Supervised Deep Learning for Vehicle Detection in High-Resolution Satellite Imagery
猜你喜欢

MySql的Sql语句的练习(试试你能写出来几道呢)

001_旭日X3派初探:开箱测试

Qlik Sense 赋值详解(Set、Let)

关于梯度下降法的一些优化方法

Kettle 从资源库中载入新的转换出错(Invalid byte 1 of 1-byte UTF-8 sequence)

自监督论文阅读笔记 SimCLRV2 Big Self-Supervised Models are Strong Semi-Supervised Learners

【第三周】ResNet+ResNeXt

深度学习基本概念
MMU 介绍-[TBL/page table work]

自监督论文阅读笔记 Self-Supervised Deep Learning for Vehicle Detection in High-Resolution Satellite Imagery
随机推荐
九、请介绍类加载过程,什么是双亲委派模型?
自监督论文阅读笔记: MoCoV2使用动量对比学习改进基线
借助ginput函数在figure窗口实时读取、展示多条曲线的坐标值
常见的电容器有哪些?唯样商城
C# 数组之回溯法
new / malloc / delete / free之间的区别
VCC(电源)和 GND(地)之间电容的作用
常见的电子元器件分类介绍
深度学习理论课程第八、九、十章总结
ucosII OSMemCreate()函数的解析
ZEMAX | 在设计抬头显示器(HUD)时需要使用哪些工具?
classpath:与classpath*的比较
Makefile
JSP的基本使用
Mysql 外键详解(Foreign Key)
三分钟看懂二极管的所有基础知识点
MATLAB自带的dwt2和wavedec2函数实现基于小波变换的自适应阈值图像边缘检测
HANA 常用数据类型详解
SAP HANA 新增一列时报错详解
opencv目标检测