简体   繁体   English

在 Qt 项目中包含独立于路径的外部库

[英]Include external library in Qt project indipendently of path

I am developing a C++ app with Qt that depends on the GNU Scientific Library (GSL).我正在开发一个 C++ 应用程序,其 Qt 依赖于 GNU 科学库 (GSL)。

So far, I have linked GSL in the .pro file using LIBS += /path/to/my/GSL/location -l<name_of_the_library> and it works, but it depends on where I installed GSL.到目前为止,我已经使用LIBS += /path/to/my/GSL/location -l<name_of_the_library>.pro文件中链接了 GSL,它可以工作,但这取决于我安装 GSL 的位置。 I'd like the .pro file not to depend on the user-specific GSL path, and possibly include the precompiled libraries (for different OSes) in the project folder.我希望.pro文件不依赖于用户特定的 GSL 路径,并且可能在项目文件夹中包含预编译的库(用于不同的操作系统)。

Is this possible?这可能吗?

In this case it works on all platforms.在这种情况下,它适用于所有平台。 You have to separate the directory from the library name您必须将目录与库名称分开

LIBS += -L/path/to -lpsapi

In this case You store your lib files in the project directory.在这种情况下,您将 lib 文件存储在项目目录中。

LIBS += -L"$$_PRO_FILE_PWD_/3rdparty/libs/" -lpsapi

look at this for more: https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html查看更多信息: https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM