当前位置:网站首页>Creation and use of static library (win10+vs2022
Creation and use of static library (win10+vs2022
2022-06-27 14:59:00 【Alexabc3000】
The creation of static library
Use VS2022 New empty project , The project is called MyStaticLib, The folder where the project is located is “E:\temp”.

Click Create , That is to complete the creation of the project .
stay VS2022 Of “ Solution explorer ” In the view , Add name is “MyStaticLib.h”( The file name can be any ) The header file ( Right click “ The header file - add to - New item - The header file ”),

Enter the following code :
#ifndef _MY_STATIC_LIB_H_
#define _MY_STATIC_LIB_H_
int my_static_add(int a, int b);
#endifstay VS2022 Of “ Solution explorer ” In the view , Add name is “MyStaticLib.cpp”( The file name can be any ) Of C++ file ( Right click “ Source file - add to - New item -C++ file ”),
#include "MyStaticLib.h"
int my_static_add(int a, int b)
{
return a+b;
}In the project property page , Change the configuration type to “ Static library (.lib)”.

Build solution , The library file can be generated “ E:\temp\MyStaticLib\x64\Debug\MyStaticLib.lib”.
The use of static libraries
Use VS2022 New empty project , The project is called MyApp, The folder where the project is located is “E:\temp”.
stay VS2022 Of “ Solution explorer ” In the view , For projects MyApp Add name is “main.cpp”( The file name can be any ) Of C++ file ( Right click “ Source file - add to - New item -C++ file ”), Enter the following code :
#include <iostream>
// The header file containing the static library
#include "E:\temp\MyStaticLib\MyStaticLib.h"
int main()
{
int a = 3, b = 5;
int c = my_static_add(a, b);
std::cout << "my_static_add(" << a << "," << b << ") = " << c << std::endl;
return 0;
}
At this point, the solution is generated , A link error occurs , The error message is :
main.obj : error LNK2019: Unresolved external symbols "int __cdecl my_static_add(int,int)" ([email protected]@[email protected]), function main The symbol is quoted in
This is an error caused by the connector not finding the library file , The solution is :MyApp Project property page , The linker , Input , Additional dependency , Add dependency “E:\temp\MyStaticLib\x64\Debug\MyStaticLib.lib”

Build solution , The executable file can be generated “E:\temp\MyApp\x64\Debug\MyApp.exe”.
On the command line, enter the directory “E:\temp\MyApp\x64\Debug\”, function MyApp.exe, The operation results are as follows :

边栏推荐
- 注解学习总结
- Jupiter core error
- Hyperledger Fabric 2. X custom smart contract
- Design and implementation of reading app based on Web Platform
- 巧用redis实现点赞功能,它不比mysql香吗?
- ReentrantLock、ReentrantReadWriteLock、StampedLock
- 522. 最长特殊序列 II / 剑指 Offer II 101. 分割等和子集
- Buuctf Misc
- Redis master-slave replication, sentinel mode, cluster cluster
- 海外仓知识科普
猜你喜欢
![[high concurrency] deeply analyze the callable interface](/img/24/33c3011752c8f04937ad68d85d4ece.jpg)
[high concurrency] deeply analyze the callable interface

Lei Jun lost another great general, and liweixing, the founding employee of Xiaomi No. 12, left his post. He once had porridge to create Xiaomi; Intel's $5.4 billion acquisition of tower semiconductor
![[business security 03] password retrieval business security and interface parameter account modification examples (based on the metinfov4.0 platform)](/img/29/73c381f14a09ecaf36a98d67d76720.png)
[business security 03] password retrieval business security and interface parameter account modification examples (based on the metinfov4.0 platform)

Redis master-slave replication, sentinel mode, cluster cluster

ThreadLocal之强、弱、軟、虛引用
![[WUSTCTF2020]girlfriend](/img/a8/33fe5feb7bcbb73ba26a94d226cc4d.png)
[WUSTCTF2020]girlfriend

Reflection learning summary

All you want to know about large screen visualization is here

Massive data! Second level analysis! Flink+doris build a real-time data warehouse scheme

Julia1.1 installation instructions
随机推荐
522. longest special sequence II / Sword finger offer II 101 Split equal sum subset
基于WEB平台的阅读APP设计与实现
Four characteristics of transactions
Abnormal analysis of pcf8591 voltage measurement data
HTTP Caching Protocol practice
Je veux acheter des produits à revenu fixe + mais je ne sais pas quels sont ses principaux investissements.
基于Vue+Node+MySQL的美食菜谱食材网站设计与实现
LVI: feature extraction and sorting of lidar subsystem
Cannot determine value type from string ‘<p>1</p>‘
Synchronized与锁升级
Redis CacheClient
Vscode uses yapf auto format to set the maximum number of characters per line
In the past, domestic mobile phones were arrogant in pricing and threatened that consumers would like to buy or not, but now they have plummeted by 2000 for sale
Library management system
How QT sets some areas to be transparent in the background image
Step by step expansion of variable parameters in class templates
Pri3d: a representation learning method for 3D scene perception using inherent attributes of rgb-d data
Redis master-slave replication, sentinel mode, cluster cluster
2022-06-27日报:Swin Transformer、ViT作者等共话:好的基础模型是CV研究者的朴素追求
老师能给我说一下固收+产品主要投资于哪些方面?