当前位置:网站首页>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.
边栏推荐
- MATLAB自带的dwt2和wavedec2函数实现基于小波变换的自适应阈值图像边缘检测
- ASP.NET MVC3的伪静态实现
- 虚拟地址空间布局
- 2021-04-30
- softmax和最大熵
- 2021-03-22
- 三、final、finally、 finalize有什么不同?
- 梯度下降、反向传播
- 自监督论文阅读笔记 SimCLRV2 Big Self-Supervised Models are Strong Semi-Supervised Learners
- 自监督论文阅读笔记Reading and Writing: Discriminative and Generative Modelingfor Self-Supervised Text Recogn
猜你喜欢
随机推荐
STM32启动文件的选择
自监督论文阅读笔记Efficient Self-supervised Vision Pretraining with Local Masked Reconstruction
自监督论文阅读笔记DisCo: Remedy Self-supervised Learning on Lightweight Models with Distilled Contrastive
解决Gradle Download缓慢的百种方法
window下VS2022封装静态库以及调用静态库
三分钟看懂二极管的所有基础知识点
IPC通信 - 管道
SolidWorks 操作视频 | 流体分析结果演示
全球一流医疗技术公司如何最大程度提高设计工作效率 | SOLIDWORKS 产品探索
【第三周】ResNet+ResNeXt
交叉熵(第六周)
八、抽象类的接口的区别
double型数据转字符串后通过MCU串口发送
Gradle插件与代理服务器导致Sync Project失败的问题
MCU接收串口字符型数据转换成数据型数据
KASLR-内核地址空间布局随机化
神经网络之感知机
自监督论文阅读笔记 Self-supervised Label Augmentation via Input Transformations
自监督论文阅读笔记 DenseCL:Dense Contrastive Learning for Self-Supervised Visual Pre-Training
[XSS, file upload, file inclusion]








