Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Extending the INCLUDEPATH and LIBS dirs globally in QtCreator
Forum Updated to NodeBB v4.3 + New Features

Extending the INCLUDEPATH and LIBS dirs globally in QtCreator

Scheduled Pinned Locked Moved General and Desktop
qtcreatorincludepathlibscplusincludepatlibrarypathldlibrarypath
3 Posts 1 Posters 3.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Daylight
    wrote on last edited by
    #1

    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 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/opt/lib
    export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$HOME/opt/include/asyncplusplus
    export LIBRARY_PATH=$LIBRARY_PATH:$HOME/opt/lib

    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?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Daylight
      wrote on last edited by Daylight
      #2

      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:

      include($$(HOME)/.qtcreator.conf)
      

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

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Daylight
        wrote on last edited by
        #3

        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/user.sh file like this:

        #!/bin/bash
        if [ -f ~/.username.bashrc ]; then
            . ~/.username.bashrc
        fi 
        

        ~/.username.bashrc contains my environment variables.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved