Fail to link header files



  • Hi :)

    I am using Code:Blocks to compile my code on Raspbian. I have already listed all the QT4 header file directories in the search directory under compiler. When I code, everything works normally, but when I build my code, it can't link the header files.

    For what I mean is in my code, i #include <QApplication>. After that when I attempt to build it the error rises in qapplication.h, stating that #include <qtcore/size.h> is invalid, size.h is not found. (The include is just example, I am just using that to state my problem)

    I am positive that the files are all there, it's just in the same folder as qapplication.h

    I am wondering what step did I missed. Is this because I wrongly declared the environment variables? Or is because it should be #include <qtcore/size>? If so, how should I edit the header files? I didn't list the .dll files in the search directory, as from what I know there shouldn't be any.

    While working in windows there aren't any problems though. I am new here, and I hope to learn more, thus I insist using Code:Blocks because I have to do a lot of things manually.

    Hoping for answers :) Thanks



  • Well, I'm not really skilled with this stuff yet (still a newbie, learning). But it looks like, if you're having an issue with qapplication.h, you may need to...

    #include "qapplication.h"
    

    If your personal header file is screwed up, you may need to...

    #include "yourapp.h" 
    

    in the .cpp file.



  • Have you tried the -Idir option? This puts a directory to the standard search path for default headers.
    Maybe, there is missed such an option to the compiler configuration settings at your codeBlocks IDE.



  • To crisosphinx,

    I tried but results to the same error.

    To nischu,

    No, I haven't try the -ldir option. What's that suppose to be?

    From learcpp.com:
    “#include <filename> tells the preprocessor to look for the file in a special place defined by the operating system where header files for the C++ runtime library are held. ”

    I didn't define anything to the Raspbian... is that the case? How should I define it then?



  • @Penguin

    """
    “#include <filename> tells the preprocessor to look for the file in a special place defined by the operating system where header files for the C++ runtime library are held. ”

    I didn't define anything to the Raspbian... is that the case? How should I define it then?
    """

    That is why I suggested #include "qapplication.h" and #include "yourapp.h". It references either the QApplication header file or the header file from your project. But if my suggestion didn't work, what does your .pro file look like? There may be an issue located within that.

    I am working on a project within Raspbian as well, but pre-creating my program on my Windows PC and compile-testing on my PC before I swap it over. I've not noticed any sort of issue outside of file structure/ folder structure in Raspbian (because it's a Linux OS). If you wish, I can message you later when I get back home and help debug your issue.



  • @chrisosphinx

    My .pro file:

    QT += core gui

    CONFIG += debug

    TARGET = MA1
    TEMPLATE = app

    HEADERS += functions.h
    SOURCES += main.cpp
    SOURCES += display_window.cpp
    SOURCES += question_generator.cpp

    !exists(main.cpp)
    {
    error("No main.cpp file found")
    }

    So I retried your suggestion and noticed something:

    When I #include <QPushButton>, the folder Code:Blocks look up is /usr/include/qt4/QtGui/qpushbutton.h

    When I #include “qpushbutton.h”, the folder is /usr/include/qt4/QtGui/qpushbutton.h

    That's the only difference I got, and I'm not sure if that's the whole main point of my mistake so I decided to show them to you

    The message is the same “fatal error: QtGui/qabstractbutton.h: No such file or directory”

    While the qpushbutton.h #include <QtGui/qabstractbutton.h>

    By the way I got curious and check if the header file is really in the directory... Well it sure is...

    Lot of thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.