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. External Header files not found in Qt Creator 2.7.0 (Qt 5.0.2, 32 bit)
Forum Updated to NodeBB v4.3 + New Features

External Header files not found in Qt Creator 2.7.0 (Qt 5.0.2, 32 bit)

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 4 Posters 16.6k 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.
  • A Offline
    A Offline
    amitqt
    wrote on last edited by
    #1

    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 directory

    If 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 2010

    I 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?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      code_fodder
      wrote on last edited by
      #2

      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:"?

      1 Reply Last reply
      0
      • C Offline
        C Offline
        code_fodder
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          amitqt
          wrote on last edited by
          #4

          Yep, its windows.
          the lines in .pro is:
          @QT += core gui

          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

          TARGET = test
          TEMPLATE = app

          INCLUDEPATH += E:\prdir

          SOURCES += main.cpp
          mainwindow.cpp

          HEADERS += mainwindow.h
          ../empty.h

          FORMS += mainwindow.ui@

          Also i had installed mingw qt also, now removed.
          Note, things worked before in fresh qt 5.0.1 install

          1 Reply Last reply
          0
          • C Offline
            C Offline
            code_fodder
            wrote on last edited by
            #5

            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!).

            1 Reply Last reply
            0
            • A Offline
              A Offline
              amitqt
              wrote on last edited by
              #6

              I have tried both with "/" and "\", but no difference.
              Also note that the autocomplete feature is working well and finds "empty.h"

              somehow the compiler is not able to search for the headerfiles?

              1 Reply Last reply
              0
              • C Offline
                C Offline
                code_fodder
                wrote on last edited by
                #7

                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...

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  code_fodder
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    amitqt
                    wrote on last edited by
                    #9

                    You are right,
                    There is no mention of the required includefolder paths in the detailed build output.

                    Any suggestions, why so? some bug?

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      code_fodder
                      wrote on last edited by
                      #10

                      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...

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        amitqt
                        wrote on last edited by
                        #11

                        I had qt reinstalled, and now it does not look at changes in .pro file.
                        Anyway to remove qt 100% and reinstall?
                        Ill try on a diff system and see.

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          code_fodder
                          wrote on last edited by
                          #12

                          :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 :)

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            amitqt
                            wrote on last edited by
                            #13

                            Sorry for replying late, I'll just input my understanding here.
                            The problem is most probably that at fails to run qmake every time, so try qmake manually when ever making changes in .pro file.
                            It seems a bug, but at least we know it.

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              code_fodder
                              wrote on last edited by
                              #14

                              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 :)

                              1 Reply Last reply
                              0
                              • A Offline
                                A Offline
                                amitqt
                                wrote on last edited by
                                #15

                                :) 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 :)

                                1 Reply Last reply
                                0
                                • S Offline
                                  S Offline
                                  Sozos
                                  wrote on last edited by
                                  #16

                                  So What was the solution ? I'm frustrated

                                  1 Reply Last reply
                                  0
                                  • B Offline
                                    B Offline
                                    blueblood
                                    wrote on last edited by
                                    #17

                                    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")
                                    
                                    1 Reply Last reply
                                    1

                                    • Login

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