How to use third-party libraries in Visual Studio

Reference blog https://blog.csdn.net/puttytree/article/details/7838419

1. Basic knowledge

The basic principle

In the project configuration, it is best not to use relative paths, let alone absolute paths, and try to use macros to specify all paths;

Common macros

The macros that can be used in the project settings can be found at the following path:

解决方案资源管理器 -> 属性 -> C/C++ -> 常规 -> 附加包含目录

Common macros in project settings

macro meaning
ConfigurationNamecol Configuration name, usually Debug or Release
IntDir The intermediate directory used by the compiler to produce obj files
OutDir output directory used by the linker
ProjectDir project directory
ProjectName project name
SolutionDir Solutions Directory
TargetDir The directory where the target output file is located
TargetExt extension of target output
TargetFileName target output filename, including extension
TargetName target output name, excluding extension
TargetPath The full pathname of the target output file

Second, the use of static library method

method one

Three steps:

  1. Add the header file directory of the project: Project---Properties---Configuration Properties---c/c++---General---Additional Include Directory: Add the header file storage directory.
$(SolutionDir)..\LIB\Include    //在当前解决方案路径的上级文件夹下的lib文件夹中
  1. Add the lib static library path referenced by the file: Project---Properties---Configuration Properties---Linker---General---Additional Library Directory: Add the lib file storage directory.
$(SolutionDir)..\LIB\lib
  1. Then add the lib file name referenced by the project: project---properties---configuration properties---linker---input---additional dependencies: add the lib file name
mylib.lib

Method Two

  1. Add the header file directory of the project: Project---Properties---Configuration Properties---VC++ Directory---Include Directory: Add the header file storage directory
$(SolutionDir)..\LIB\Include
  1. Add the lib static library path referenced by the file: Project---Properties---Configuration Properties---VC++ Directory---Library Directory: Add the lib file storage directory.
$(SolutionDir)..\LIB\lib

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324981206&siteId=291194637