Configuration of LIBS in QT

When referencing an external third-party library in QT, the LIBS parameter needs to be configured.

There are two ways for QT to choose a kit, MSVC and MinGW. Generally, the static library files of MSVC end with .lib, and MinGW end with .a. I will not introduce here what are C++ static libraries and dynamic libraries. In fact, such libraries are available in almost all languages: such as jar files in java language.

1. LIBS Usage

Usage: LIBS += -Lpath -lname1 -lname2
path: library file path
name1, name2: library file

1. "Library file path" can have the following forms:

2. The "library file" can have the following forms:
if there is a decoding library under the directory lib where the .pro is located, the msvc version is "test.lib", and the mingw version is "libtest.a".
(1) When -l is not added, the full name of the library file needs to be written:

This way of writing is generally not recommended, because portability is not good.

(2) When adding -l, you can mask the differences in the library file names of different compilers

3. The specific writing method when multiple library file paths and multiple library files are included:
LIBS += -L(path1) -L(path2) -l(name1) -l(name2)
It is recommended to use \ newline
LIBS in actual use += -L(path1) \
 -L(path2) \
 -l(name1) \
 -l(name2) \

reference:

(1) LIBS usage in QT

(2) User Guide for Qt qmake LIBS

Guess you like

Origin blog.csdn.net/mars21/article/details/131591992