External Header files not found in Qt Creator 2.7.0 (Qt 5.0.2, 32 bit)
-
I have installed Qt 5.0.2, also build a new Gui App, and it works fine.
But somehow any external header file is not been found by compiler.
Details:
Project dir structure:
@ -- [Folder > e:\prdir]
| -- empty.h
| -- [Project folder > test]
|-- main.cpp
|-- mainwindow.h
|-- mainwindow.cpp
|-- test.pro@in mainwindow.h, I just #include "empty.h" and in .pro file a line INCLUDEPATH += e:\prdir
and I recieved
error: e:\test\mainwindow.h:5: error: C1083: Cannot open include file: 'empty.h': No such file or directoryIf i place empty.h in Project folder it does work.
The autocomplete feature is able to find the empty.h file
This use to work before, but somehow something got wrong which i am not able to understand.
Using:
Windows 8 - 64 bit
VS 2010I had installed 4.8.2 too with 5.0.1, then uninstalled both and installed 5.0.2.
I think this broke something that i am not able to link to external header files.any help?
-
hi amitqt, can you paste in your complete .pro file, maybe there is some issue in it that is not noticed.
Generally if you have:
@
INCLUDEPATH += "path"
HEADERS += "headerfile"
@Then you have all you need. Since you are using absolute path you should not have any "relative" path issues. I can't remember if it is case sensitive for windows (if you are running in windows) but linux is, so just check that case as well :)
Also what is the path to your main project? is that also on the "e:"?
-
Sorry, just noted you are using windows!, so ignore the linux comment.
I also installed v4.x.x before upgrading to 5.0.2, I think that process is generally quite stable. You can have two versions installed with no issues (i.e. install 4.x.x and then install 5.0.2 afterwards).... at least I have not had any issues with that.
-
Yep, its windows.
the lines in .pro is:
@QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test
TEMPLATE = appINCLUDEPATH += E:\prdir
SOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
../empty.hFORMS += mainwindow.ui@
Also i had installed mingw qt also, now removed.
Note, things worked before in fresh qt 5.0.1 install -
Hmm.... probably it is easier if you have your path "lower" then your project file, i.e. in a sub directory then you only need INCLUDEPATH += prdir.
However, one thing I notice is the slash in E:\prdir is the same as the end of line slash. I am not sure if that will work. I'll have to look at an example, but you may need to either change the slash from "" to "/" or put it in quotes... when I get a chance I will take a look if that's an issue (or you can try it!).
-
Well, infact that all worked on my project, regardless of the direction of the slash.
What happens if you use the following:
@HEADERS += mainwindow.h
E:/prdir/empty.h@Since it is not working, it does seem you may have a strange issue... but see if that absolute path at least works...
-
The next thing to look at is the compile out put. In the "Compile Output" window can you print out the .cpp file compile, it should look something like (where the bold is the include paths):
g++ -c -pipe -fno-keep-inline-dllexport -Wall -Wno-unused-parameter -Xlinker -Map=mvp.map -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_MULTIMEDIA_LIB -DQT_GUI_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I. -I'config' -I'lib' -I'managers' -I'mvp' -I'smCmce' -I'smCtl' -I'smMm' -I'utils' -I'../../../Qt/Qt5.0.2/5.0.2/mingw47_32/include' -I'../../../Qt/Qt5.0.2/5.0.2/mingw47_32/include/QtMultimedia' -I'../../../Qt/Qt5.0.2/5.0.2/mingw47_32/include/QtGui' -I'../../../Qt/Qt5.0.2/5.0.2/mingw47_32/include/QtXml' -I'../../../Qt/Qt5.0.2/5.0.2/mingw47_32/include/QtNetwork' -I'../../../Qt/Qt5.0.2/5.0.2/mingw47_32/include/QtCore' -I'../_out' -I'../../../Qt/Qt5.0.2/5.0.2/mingw47_32/mkspecs/win32-g++' -o ../_out/cconfigxml.o config/cconfigxml.cpp
-
Not sure about what can cause it. But here is a few things to try:
In your .pro file try to add the path manually with the QMAKE_CXXFLAGS variable. Also keep your INCLUDEPATH += E:\prdir as well, so somthing like:
@
INCLUDEPATH += E:\prdir
QMAKE_CXXFLAGS += -I'E:\prdir'This will print the two variables out and you can see what is in them...
message (INCLUDEPATH: $$INCLUDEPATH)
message (QMAKE_CXXFLAGS: $$QMAKE_CXXFLAGS)
@This will test if the vars are getting populated correctly. Also will test if the QMAKE_CXXFLAGS var works or if that also has a problem. It might lead to more clues...
-
:o
It does sound like you have some strange issue... probably you are right to try it on a different PC, we could be looking at this for a while otherwise :)
-
late reply?....that was like 6 months ago, lol ;)
To be honest, I have since come across various installs on Qt on different peoples PCs. The safest way is to install fresh (remove old installs first) and install using the SDK. Personally I have no issues with auto .pro file updating, but I see colleagues who have installed qt in "bits" who do. There is something (not figured out what yet) that controls the qmake (and other) processes.
But, running qmake manually is a valid alternative, thanks for that :)
-
:) yep, sorry again for late late reply.
The problem didn't get solved then, but after few month. So I just related incase any one gets stuck!I am also planning to make a simple custom version control and folder sync and Qt has this directory watch api's, just hope it works well when there are some issues in their own ide , but those two maybe unrelated :)
-
Use CMake instead of qmake. This is not as straightforward as it it should but it worked for me after hours of frustration.
The library I wanted to link in was Fruit. It has CMakeLists.txt file which means it supports CMake without needing to build it first outside the project. Actually, trying to build it outside the project, and linking it, like so:set(FRUIT_DIR "../path/to/fruit_build") include_directories(${FRUIT_DIR}/include) library_directories(${FRUIT_DIR}/lib)
still didn't find the headers for fruit.
This is how it worked:add_subdirectory("../path/to/fruit_source" "../build_dest") include_directories("../path/to/fruit_source/include")