Important: Please read the Qt Code of Conduct -

Extending the INCLUDEPATH and LIBS dirs globally in QtCreator

  • Hello everyone!
    I'm trying to add custom include directories to ones defined in QtCreator(3.3.0) by default. I tried setting environment variables in ~/.bashrc file:

    export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$HOME/opt/include/asyncplusplus

    It works well for gcc itself when used from shell, but QtCreator ignores this. If I define these variables also in the Kit options^1 - build succseeds but syntax highlighting and completition does not work.

    The only way to make QtCreator fully support external libraries I have found so far - is to set LIBS and INCLUDEPATH variables in .project file. Which is not satisfactory for me because these paths are different on different systems and puting .project file under version control becomes a nightmare. An example would be boost: on *nix boost is normally accessible from the default include path, but not on Windows...

    I have found some hints, that I could achieve a desired behaviour by modifing .conf files in Qt/5.4/gcc_64/mkspecs/common, but I don't know how to do it correctly.

    What is the best way to solve this problem?

  • I found a solution myself. Not sure if it's a "right" one:
    create a ~/.qtcreator.conf file containing this:

    QMAKE_INCDIR += $$(HOME)/opt/include
    QMAKE_LIBDIR += $$(HOME)/opt/lib

    append this:


    to qtcreator_installation/5.4/gcc_64/mkspecs/common/linux.conf

  • I have found a reason, why LD_LIBRARY_PATH, CPLUS_INCLUDE_PATH and LIBRARY_PATH variables were ignored by QtCreator: I use KDE and it does not load the .bashrc in the session, but the bash does. So in KDE when you open Konsole - your environment is populated from .bashrc, but other apps, not launched from console - have different environment. So for me the solution was to create $HOME/.kde/env/ file like this:

    if [ -f ~/.username.bashrc ]; then
        . ~/.username.bashrc

    ~/.username.bashrc contains my environment variables.