Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to add an external .a library in Qt Creator project via GUI?



  • 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":http://doc.qt.nokia.com/qtcreator-2.2/creator-project-qmake-libraries.html#to-add-libraries, 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.

    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



  • The easiest and quickest way is to add it to the .pro file in the editor:

    @
    INCLUDEPATH += C:/path/to/includedir
    LIBS += -LC:/path/to/libdir -lyaml-cpp
    @


  • Moderators

    The documentation you reference are about adding a static library to your project: Not only to use it, but to have it built from sources as part of your project. I am not sure that is what you want.

    I usually just add it to the LIBS in the relevant .pro file, just like Volker suggested.

    You should also be able to right-click your project and select "Add library" from the context menu there.


Log in to reply