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. Cannot compile code against qt4

Cannot compile code against qt4

Scheduled Pinned Locked Moved Installation and Deployment
3 Posts 2 Posters 1.0k 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.
  • P Offline
    P Offline
    publicus
    wrote on last edited by
    #1

    Hello, I'm running ArchLinux and recently installed Qt4 and Qt5. However, the tutorial that I'm going through requires Qt4.

    Here is my code.
    [code]#include <QApplication>
    #include <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();
    }[/code]

    I then did the following:
    [code]% qmake -project
    % qmake
    % make[/code]

    And this is what I got:
    [code]g++ -c -pipe -march=i686 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I. -I. -I/usr/include/qt -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -o hello_world.o hello_world.cpp
    hello_world.cpp:3:24: fatal error: QApplication: No such file or directory
    #include <QApplication>
    ^
    compilation terminated.
    Makefile:298: recipe for target 'hello_world.o' failed
    make: *** [hello_world.o] Error 1[/code]

    How do I point to the correct headers/libraries?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      publicus
      wrote on last edited by
      #2

      I got it! I used the tool qtchooser to run qmake so that when the Makefile is generated, it's generated with Qt4 in mind. The process was something like this:
      [code]qmake -project && qtchooser -run-tool=qmake -qt=4 && make[/code]

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        You should be able to go through the same tutorial using Qt 5 with some minor modifications like

        @QT += widgets@

        when using widgets in your application (the error you are currently getting using Qt 5's qmake)

        In between, and since you found a solution (thanks for sharing by the way) please update the thread title prepending [solved] so other forum users may know a solution has been found :)

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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