当前位置:网站首页>Use VS to create a static link library Lib and use
Use VS to create a static link library Lib and use
2022-06-29 04:44:00 【Coffee and oolong】
One 、 Use VS Create a static link library .lib
Create a VS project
* It could be a Empty item or VS The built-in Static library project Templates

*
Empty itemThere is no original code or file in , I prefer this mode*
Static libraryThe project has some original code and files , amongpch.hIs a precompiled header file , Used to speed up compilation performance ;framework.hFiles are automatically generated and can be ignoredSet the corresponding compilation options
*
Empty item: Item attribute — Configuration properties — routine — Configuration type — choice Static library (.lib)*
To configureandplatformYou can choose Debug、Win32 Or other settings , The caller can use the same configuration
* Extra reminder : Toolbar configuration and platform selection With the above Configuration and platform selection of the attribute interface It's a thing

Add code and generate
* Add what you need
The header file (.h)andSource file (.cpp)
* Compile and generateresult
Generated after , You can find the corresponding... According to the output prompt
.lib fileThe location of
Static library project: The configuration type has been set to... By defaultStatic library (.lib)了 , Its original files can be left untouched , Add... In additionThe header file (.h)andSource file (.cpp)that will do
Two 、 Use static link libraries in your projects .lib
Mode one :
Copy the static library
The header file (.h)andThe library files (.lib)Go to project directoryAfter copying to the project directory , take
The header file .hAdd to project : The header file — add to — Existing items — Find the header file to addAdd... To the project properties
The library files (.lib)Item attribute — Configuration properties — The linker — Input — Additional dependency — Write in the library file name
Include... In the code
The header file (.h)// main.cpp In file #include "LibTest.h" // Suppose my file name is LibTest.hmatters needing attention :
Platform used by the library (x64、x86) And configuration (release、debug) Should be consistent with the caller project
Mode two : Don't depend on VS platform , Call... At the code level
#pragma comment(lib, "LibTest.lib") // When the library file is in the project directory , The relative path is used
#include "LibTest.h"
#pragma comment(lib, "D:\\ desktop \\LibTest.lib") // You can also use absolute paths
#include "LibTest.h"
Mode three : Direct will lib Add to the resource file of the project

边栏推荐
- Memo pattern
- Continue yesterday's plan: February 16, 2022
- I haven't encountered these three problems. I'm sorry to say that I used redis
- Collection of common terms used in satellite navigation
- JVM_ 16_ Garbage collector
- GBASE 8s must be a DBSA、路径更改导致无法启动的解决方法
- 1018 hammer scissors cloth
- Technical parameters of Tektronix DPO4104 digital fluorescence oscilloscope
- JVM memory tuning method
- The subnet of the pool cannot be overlapped with that of other pools.
猜你喜欢

It is said on the Internet that a student from Guangdong has been admitted to Peking University for three times and earned a total of 2million yuan in three years

The subnet of the pool cannot be overlapped with that of other pools.

LabVIEW displays Unicode characters

Redis cache penetration, cache breakdown, cache avalanche

Composite pattern

【HackTheBox】dancing(SMB)

Introduction to Bert and Vit

An efficient flutter hybrid stack management scheme with zero intrusion, you deserve it!

波形记录仪MR6000的实时波形运算功能

Technical parameters of Tektronix DPO4104 digital fluorescence oscilloscope
随机推荐
Software architecture experiment summary
What are the circular statements of MySQL
什么是匿名内部类,如何使用匿名内部类
Cipher
JVM_ 16_ Garbage collector
网络设备设置/取消console口登陆单独密码
How to write MySQL scheduled backup script in Linux
没遇到过这三个问题都不好意思说用过Redis
Go Foundation (I)
泰克TDS3054B示波器技术指标
泰克DPO4104数字荧光示波器技术参数
How to solve startup failure due to insufficient MySQL memory
轻松入门自然语言处理系列 专题7 基于FastText的文本分类
Mvcc principle in MySQL
Observer pattern
如何用万用表测试电子部件
[结构力学] 结点承载下影响线与直接承载下影响线不同的原因
波形记录仪MR6000的实时波形运算功能
Has my future been considered in the cloud native development route?
Airflow2.2.3 + efficiency + MySQL 8 build a robust distributed scheduling cluster