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

边栏推荐
猜你喜欢
代码没写完,哪里有脸睡觉!17 张程序员壁纸推荐

ZEMAX | 探索 OpticStudio中的序列模式

对象の使用

003_旭日X3派初探:利用无线串口通信控制舵机

Qlik Sense 聚合函数及范围详解(Sum、Count、All、ToTaL、{1})

自监督论文阅读笔记 Incremental-DETR:Incremental Few-Shot Object Detection via Self-Supervised Learning

Makefile

自监督论文阅读笔记 Self-Supervised Visual Representation Learning with Semantic Grouping

ZEMAX | 如何围绕空间中的任何点旋转任何元素

交叉熵(第六周)
随机推荐
自监督论文阅读笔记Efficient Self-supervised Vision Pretraining with Local Masked Reconstruction
@JsonProperty和JSONField的区别?
自我监督学习和BERT模型
Qlik Sense 字符串截取和拼接详解(Left、Right、&)
ZEMAX | 如何围绕空间中的任何点旋转任何元素
new / malloc / delete / free之间的区别
Qlik Sense 赋值详解(Set、Let)
MySql的Sql语句的练习(试试你能写出来几道呢)
三、final、finally、 finalize有什么不同?
PCB设计经验之模拟电路和数字电路区别为何那么大
时间盲注脚本
Mysql 存储过程详解(procedure)
001_旭日X3派初探:开箱测试
自监督论文阅读笔记FIAD net: a Fast SAR ship detection network based on feature integration attention and self
Kotlin 中的泛型介绍
ZEMAX | 在设计抬头显示器(HUD)时需要使用哪些工具?
二阶段提问总结
window下VS2022封装动态库以及调用动态库
ZEMAX | 探究 OpticStudio 偏振分析功能
【第三周】ResNet+ResNeXt