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

电子元器件之电子变压器可分为哪几类?

A.1#【内存管理】——1.1.3 page: struct page

002_旭日X3派初探:TogetherROS安装

进程间通信IPC - 信号量

Gradle插件与代理服务器导致Sync Project失败的问题

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

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

【第二周】卷积神经网络

KASLR-内核地址空间布局随机化
随机推荐
001_旭日X3派初探:开箱测试
PCB设计经验之模拟电路和数字电路区别为何那么大
SAP HANA 新增一列时报错详解
ZEMAX | 在OpticStudio中建立扩增实境(VR)头戴式显示器
Oracle 注释详解(--、/**/、rem)
自监督论文阅读笔记 Ship Detection in Sentinel 2 Multi-Spectral Images with Self-Supervised Learning
window下VS2022封装静态库以及调用静态库
servlet学习(七)ServletContext
2021-03-22
ZEMAX | 如何倾斜和偏心序列光学元件
enum和enum class的区别
滚动条 scrollbar 和scrollbar-thumb 样式
动漫 吞噬星空
自监督论文阅读笔记 Self-supervised Learning in Remote Sensing: A Review
page fault-页异常流程
Oracle 分区索引详解(local、global)
常见的电子元器件分类介绍
JSP的基本使用
c#,.net 下载文件 设置断点
自监督论文阅读笔记 Self-Supervised Deep Learning for Vehicle Detection in High-Resolution Satellite Imagery