如何通过 GUI 在 Qt Creator 项目中添加外部 .a 库? [英] How to add an external .a library in Qt Creator project via GUI?
问题描述
我使用 Qt 的 mingw 编译器构建了 yamlcpp 静态 (libyaml-cpp.a) 库.现在我想将它添加到我的项目中.我使用 这个 qt 文档,但 Qt Creator 只允许选择 *.lib 文件而不是 *.a 文件(在选择文件对话框中).这很令人困惑,因为我使用的是 MinGW 4.4 调试配置,而不是 MSVC2008.
I've built yamlcpp static (libyaml-cpp.a) library using Qt's mingw compiler. Now I want to add it to my project. I use this qt doc, but Qt Creator allows to select only *.lib files not *.a files (in Choose file dialog). That's confusing because I'm using MinGW 4.4 debug configuration, not MSVC2008.
是否可以通过 Qt Creator 的 GUI 添加 *.a 库,我该怎么做?Windows 7、Qt Creator 2.3.1、Qt 4.7.4
Is it possible to add *.a libraries via Qt Creator's GUI and how do I do it? Windows 7, Qt Creator 2.3.1, Qt 4.7.4
推荐答案
据我所知现在是不可能的.唯一的方法是编辑 .pro 文件并添加以下行:
As far as I know it is impossible now. The only way is to edit .pro file and add such lines:
win32 {
#/* If you compile with QtCreator/gcc: */
win32-g++:LIBS += -L"$$_PRO_FILE_PWD_/libs/"
win32-g++:LIBS += -lyaml-cpp
#/* IF you compile with MSVC:
#win32-msvc:LIBS += /path/to/your/libMyLib.lib*/
}
macx {
LIBS += -L"$$_PRO_FILE_PWD_/libs/"
LIBS += -lyaml-cpp-mac
}
这篇关于如何通过 GUI 在 Qt Creator 项目中添加外部 .a 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!