如何在C ++ Qt Creator中使用库

how to use a library in c++ Qt creator

本文关键字:Creator Qt      更新时间:2023-10-16

我下载了一个用于处理DicOM文件的库。
库的树是:

|--include
        |-----dicom.h
        |-----dicomcfg.h
|--lib
     |--------dicomsdl.lib

但是我不知道如何使用和内置Qt Creator。
如果有人能帮助我,我将不胜感激。

我假设你使用 qmake 作为你的构建系统。要链接您的"外部"库,您需要在 .pro 文件中进行以下更改:

#path to includes directory of your library, qmake will try to find includes there
INCLUDEPATH += /path/to/library/include
#path to pre-compiled library directory
LIBS += -L/path/to/precomp/library
#link your pre-compiled library, -l<library name> w/o .so, .a, .lib, lib- prefix
LIBS += -ldicomsdl

也许您需要使用编译器从源代码构建库。如果编译器不匹配,可能会有一些麻烦。