Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. I'm unable to compile my first programme it says "/usr/local/qt4/include/QtCore/qstring.h:54:20: fatal error: string: No such file or directory"
Qt 6.11 is out! See what's new in the release blog

I'm unable to compile my first programme it says "/usr/local/qt4/include/QtCore/qstring.h:54:20: fatal error: string: No such file or directory"

Scheduled Pinned Locked Moved Installation and Deployment
5 Posts 4 Posters 4.3k 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
    aditya.rajan1
    wrote on last edited by
    #1

    Hello i'm new to qt i'm just rying to compile an example code but it show error here is my code @#include <QtGui/QApplication>
    #include <QtGui/QWidget>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    QWidget window;
    
    window.resize(250, 150);
    window.setWindowTitle("Simple example");
    window.show();
    
    return app.exec();
    

    }@ HERE IS THE ERROR @In file included from /usr/local/qt4/include/QtCore/qobject.h:48:0,
    from /usr/local/qt4/include/QtCore/qcoreapplication.h:45,
    from /usr/local/qt4/include/QtGui/qapplication.h:45,
    from /usr/local/qt4/include/QtGui/QApplication:1,
    from n_0.c:1:
    /usr/local/qt4/include/QtCore/qstring.h:54:20: fatal error: string: No such file or directory

    include <string>

                    ^
    

    compilation terminated.
    make: *** [n_0.o] Error 1
    @ THIS ERROR IS QUITE BIG BUT I PASTED only the essential part needed to solve my problem here

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SherifOmran
      wrote on last edited by
      #2

      add
      @
      #include <QString>

      @

      1 Reply Last reply
      0
      • mranger90M Offline
        mranger90M Offline
        mranger90
        wrote on last edited by
        #3

        I suspect the problem is in your environment.
        I tested this with Qt 4.84, msvc 10, on Win7. and it compiled
        and ran as expected.

        Here is my .pro file
        @
        QT += core gui

        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

        TARGET = test
        TEMPLATE = app

        SOURCES += main.cpp
        @

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          Hi, and welcome to the Qt Dev Net!

          The Qt header <qstring.h> tries to include the standard C++ header <string>. The error messages show that your compiler could not find <string>.

          You need to install the standard C++ development files in your system.

          If you need more help, please tell us:

          What distro are you using?

          How did you install your compiler?

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aditya.rajan1
            wrote on last edited by
            #5

            thanks a lot fellas ! problem solved , actually my source file was having .c extension i changed it to .cpp and it worked !

            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