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

边栏推荐
- docker 创建的 mysql8 怎么改密码
- Alibaba microservice component Sentinel
- 2022-2028 global and Chinese industrial electronic detonator Market Status and future development trend
- Facade pattern
- 波形记录仪MR6000的实时波形运算功能
- BERT和ViT简介
- 直播预约|AWS Data Everywhere 系列活动
- Cisco voice card handling configuration
- Practical part: solving the function conflict between swagger and user-defined parameter parser
- What is the method of connection query in MySQL
猜你喜欢
随机推荐
软件体系结构实验汇总
February 14 institutional dragon and tiger list and operation of well-known hot money
044. (2.13) add value to yourself
[C language] start a thread
The subnet of the pool cannot be overlapped with that of other pools.
从零到一,教你搭建「以文搜图」搜索服务(一)
Hi, my technology forum is online!
Installation and configuration of interrealsense d435i camera driver
Research Report on the overall scale, major manufacturers, major regions, products and applications of power battery laser welding machines in the global market in 2022
Quelles sont les méthodes de simulation et de gravure des programmes? (comprend les outils communs et la façon dont ils sont utilisés)
Notebook access desktop shared disk
Blue Bridge Cup DFS (I)
Software architecture experiment summary
Technical specifications of Tektronix tds3054b oscilloscope
Untitled
如何创建 robots.txt 文件?
What if modstart forgets the background user or password?
【牛客网刷题系列 之 Verilog快速入门】~ 异步复位的串联T触发器
基于.NetCore开发博客项目 StarBlog - (13) 加入友情链接功能
Daily practice - February 15, 2022









