Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Qt Creator find included headers in included paths - even though qmake is able to find them

I joined an already existing (opensource-) Qt 4 project to add some functionality. The project compiles and runs perfectly on Linux Slackware with Qt 4.8.5. As IDE I first used KDevelop (comes with Slackware), but Qt project files aren't supported in KDevelop (since it primarily uses cmake, I had to use the makefile to import the project). Now I want to switch to Qt Creator, but header files in included (relative-) paths aren't recognized. For example the project file is in "dir0/programs/prog1/prog1.pro" and some extra headers are in "dir0/gui/extra.h". "dir0/gui" is added to the search path by the line INCLUDEPATH += ../../gui in the project file. If I hover over #include "extra.h" in a .h file of the project I always get a popup saying "extra.h: No such file or directory".

In KDevelop there was no problem and also qmake gets it. What's the problem of the Creator (I'm using 2.8, and also tried 3.0)

Any help greatly appreciated :-)

Konrad


EDIT: I just realized, that the whole Qt framework isn't recognized by qt-creator as well. When I type #include " the headers suggested by auto-completion are all located either in "/usr/include" or the project directory. For example I even can't do #include <QtGui>.

what might be the problem here?


EDIT2: The project file also includes gui.pri and local.pri which are used by several other projects as well. I tried to compress the files a bit - it still compiles without problems.

actual project file located in "dir0/programs/us_convert"

include( ../../gui.pri )
QT           += xml

TARGET        = us_convert

HEADERS       = us_convert_gui.h       \
                us_convert.h           \
                us_convertio.h         \
                us_experiment.h        \
                us_experiment_gui.h    \
                us_selectbox.h         \
                us_intensity.h         \
                us_get_dbrun.h         \
                us_mwl_data.h

SOURCES       = us_convert_gui.cpp     \
                us_convert.cpp         \
                us_convertio.cpp       \
                us_experiment.cpp      \
                us_experiment_gui.cpp  \
                us_selectbox.cpp       \
                us_intensity.cpp       \
                us_get_dbrun.cpp       \
                us_mwl_data.cpp

gui.pri located in "dir0/"

# Profile include file for applications

!include( local.pri ) error( "local.pri is missing.  Copy from local.pri.template and update variables as appropriate" )

TEMPLATE     = app
DESTDIR      = ../../bin
MOC_DIR      = ./moc
OBJECTS_DIR  = ./obj
VER          = 10

CONFIG       += $$DEBUGORRELEASE qt thread warn

unix {
  LIBS       += -L../../lib -lus_gui -lus_utils
  LIBS       += -lcrypto
  LIBS       += -lqwtplot3d-qt4 -lGLU
  LIBS       += -L$$MYSQLDIR -lmysqlclient
  DEFINES    += INTEL LINUX

  INCLUDEPATH  += $$MYSQLPATH ../../$$QWT3D/include
  INCLUDEPATH  += ../../gui ../../utils $$QWTPATH/include ..
}

And local.pri, also located in "dir0/"

DEBUGORRELEASE += debug 

unix {

  MYSQLPATH   = /usr/include/mysql/
  QWTPATH     = /usr/local/qwt-5.2.2
  SINGLEDIR   = /usr/lib/qt/qt-solutions/qtsingleapplication/src
  MYSQLDIR    = /usr/include/mysql
  QWT3D = /qwtplot3d-qt4/
  LIBS        += -L/usr/local/qwt-5.2.2/lib -lqwt

}
like image 283
user3122343 Avatar asked Dec 20 '13 10:12

user3122343


People also ask

Where are Qt header files?

The Qt header files are packaged as a zip file in the devkitBase\include directory on Windows, and as a tarred and zipped file in devkitBase/include on macOS and Linux.

Does Qt support C ++ 11?

Qt Creator is not a compiler. When you read that "Qt Creator supports C++11" it means that the code-completion engine (Clang in this case) supports C++11 syntax.

Is Qt Creator good for C++?

Qt Creator is a cross-platform (Windows, Linux, Mac) IDE that is part of the Qt SDK and is aimed at simplifying the development of cross-platform GUI applications. It is mostly used with C++ (especially with embedded devices that require UI front), but also with JavaScript and QML.

What is $$ PWD in Qt?

$$PWD means the dir where the current file (. pro or . pri) is. It means the same in LIBS . I just used it like this in my project: LIBS += -L$$PWD/deps/android -lopenal.


2 Answers

I know my answer is late, but I had the same problem and there was no solution in tons of different posts, but then I found a solution, which worked for me:

You have to add the module you are using in your .pro file:

For example, I wanted to use the #include<QtSql> module, but nothing worked. The compiler did not find this file. I found out that I was able to #include<QtSql/QSqlDatabase> (and all types which are declared in QtSql) however, but then I got an "undefined reference" error.


The Solution: You have to add the module you are using in you .pro file, in the following line:

QT = core gui

(This is how it looked by default for me) This is how it looks now for me and how it worked for me:

QT = core gui sql

Hope this helps somebody else who has got the same issues.


This worked on Windows as well as on Ubuntu!

like image 79
ElectRocnic Avatar answered Oct 06 '22 01:10

ElectRocnic


I use premake and make to build my projects and QtCreator as IDE. I had the same problem as you, using the header-only Library GLM. My source code containded the following line: #include <glm/glm.hpp>. It compiled without errors, but QT-Creator couldn't find the file, so I was not able to jump to it or functions it contains by holding CTRL and clicking on some function the library provided.

In my project folder ther is a file called "Tree.includes", where "Tree" is the name of my QT-Creator project. I had to add the path to the library I use ther and it worked.

usedLibraries/glm/

My "Tree.includes" file looks like this:

project/src
usedLibraries/glm/
usedLibraries/glew-1.11.0/include/
usedLibraries/glfw-3.0.4/include/

My project folder lookes like this:

.
├── project
│   ├── bin
│   ├── build
│   ├── gcc.txt
│   ├── include
│   ├── Makefile
│   ├── premake4.lua
│   └── src
├── Tree.config
├── Tree.creator
├── Tree.creator.user
├── Tree.files
├── Tree.includes
└── usedLibraries
    ├── glew-1.11.0
    ├── glfw-3.0.4
    └── glm
like image 45
Boris Month Avatar answered Oct 06 '22 01:10

Boris Month