当前位置:网站首页>VS2022 encapsulates static libraries and calls static libraries under window
VS2022 encapsulates static libraries and calls static libraries under window
2022-08-03 06:10:00 【Shiyu】
First, create a new project MyLib (encapsulate your own static 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 project properties -> configuration properties -> configuration type (modified to static library.lib):
4. Right-click to generate, a static library will be generated
Second, create a new project TestMyLib (calling the library just encapsulated)
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. Linker->General->Additional library directory, link to the directory where MyLib.lib is located:
4. Linker->Input->Additional dependencies, add the generated library name MyLib.lib
5. Write TestMyLib.cpp file:
#include #include "Test.h"int main(){Test t;t.say();}
6. Click to run
The reason for this problem is that the current project is the Debug version, and the referenced library file is the Release version.
Solution 1: Just change the current Debug mode to Release mode.
Solution 2: Regenerate a debug version of the library file.Then modify the linker--general--additional library directories.Re-include the directory where the debug repository is located.
边栏推荐
- 增强光学系统设计 | Zemax 全新 22.2 版本产品现已发布!
- 稳压二极管的工作原理及稳压二极管使用电路图
- Mysql 存储过程详解(procedure)
- 影响PoE供电传输距离的除了网线还有啥?
- MATLAB给多组条形图添加误差棒
- Kotlin 中的泛型介绍
- 自监督论文阅读笔记 S3Net:Self-supervised Self-ensembling Network for Semi-supervised RGB-D Salient Object Det
- 自监督论文阅读笔记 Self-supervised Learning in Remote Sensing: A Review
- 动漫 吞噬星空
- 自监督论文阅读笔记 Ship Detection in Sentinel 2 Multi-Spectral Images with Self-Supervised Learning
猜你喜欢
ZEMAX | 如何创建简单的非序列系统
2021-03-22
自监督论文阅读笔记SELF-SUPERVISED SPECTRAL MATCHING NETWORK FOR HYPERSPECTRAL TARGET DETECTION
ZEMAX | 探索 OpticStudio中的序列模式
自监督论文阅读笔记 S3Net:Self-supervised Self-ensembling Network for Semi-supervised RGB-D Salient Object Det
自监督论文阅读笔记 Incremental-DETR:Incremental Few-Shot Object Detection via Self-Supervised Learning
Typora
KASLR-内核地址空间布局随机化
自监督论文阅读笔记 Self-Supervised Visual Representation Learning with Semantic Grouping
使用JSP实现简单的登录注册功能,并且使用Session跟踪用户登录信息
随机推荐
设备树(devicetree)-dts语法
三、final、finally、 finalize有什么不同?
Dynamic adjustment subject web system?Look at this one is enough
ZEMAX | 如何创建复杂的非序列物体
关于梯度下降法的一些优化方法
MATLAB给多组条形图添加误差棒
自监督论文阅读笔记 Self-supervised Label Augmentation via Input Transformations
二阶段提问总结
double型数据转字符串后通过MCU串口发送
电子元器件之电子变压器可分为哪几类?
虚拟地址空间布局
MATLAB给多组条形图添加误差棒
深度学习理论课程第四、五章总结
cmdline -[command line,__fdt_pointer,initial_boot_params] boot_command_line 获取
东南亚跨境电商
ASP.NET MVC3的伪静态实现
布尔盲注需简化代码
自监督论文阅读笔记FIAD net: a Fast SAR ship detection network based on feature integration attention and self
Phase Vocoder的补充完善,Matlab音频变速不变调、变调不变速
使用JSP实现简单的登录注册功能,并且使用Session跟踪用户登录信息