Results 1 to 4 of 4

Thread: Qt installation under Linux

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Qt installation under Linux

    Hello,
    I'm trying to compile this simple program at command line:
    Qt Code:
    1. #include <QApplication>
    2. #include <QWidget>
    3.  
    4. int main(int argc, char* argv[]) {
    5.  
    6. QApplication app(argc, argv);
    7. w.resize(640, 480);
    8. w.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 
    I typed:
    qmake -project //ok
    qmake //ok
    make //errors
    'make' gives me a lot of errors. I suppose they depend from 'bad setting' of qt or other things under LInux.
    Just to give an idea of the problem:
    gcc -c -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I. -o main.o main.c
    In file included from /usr/include/QtCore/qobjectdefs.h:45:0,
    from /usr/include/QtCore/qobject.h:47,
    from /usr/include/QtCore/qcoreapplication.h:45,
    from /usr/include/QtGui/qapplication.h:45,
    from /usr/include/QtGui/QApplication:1,
    from main.c:1:
    /usr/include/QtCore/qnamespace.h: In function ‘QT_MODULE’:
    /usr/include/QtCore/qnamespace.h:54:1: error: unknown type name ‘namespace’
    namespace
    ^
    /usr/include/QtCore/qnamespace.h:58:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or __attribute__’ before ‘{’ token
    Qt {
    ^
    /usr/include/QtCore/qnamespace.h:1799:1: error: expected declaration specifiers before ‘Q_DECLARE_OPERATORS_FOR_FLAGS’
    Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MouseButtons)
    ^
    /usr/include/QtCore/qnamespace.h:1820:1: error: unknown type name ‘class’
    class Q_CORE_EXPORT QInternal {
    ^
    /usr/include/QtCore/qnamespace.h:1820:21: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘QInternal’
    class Q_CORE_EXPORT QInternal {
    ^
    /usr/include/QtCore/qnamespace.h:1875:2: error: expected declaration specifiers before ‘;’ token
    };
    ^
    In file included from /usr/include/QtCore/qobject.h:47:0,
    from /usr/include/QtCore/qcoreapplication.h:45,
    from /usr/include/QtGui/qapplication.h:45,
    from /usr/include/QtGui/QApplication:1,
    from main.c:1:

    [.................................................. .................................................. ................so on.......]
    Does anybody have an idea about the problem?

    Hello,
    I'm trying to compile this simple program at command line:
    Qt Code:
    1. #include <QApplication>
    2. #include <QWidget>
    3.  
    4. int main(int argc, char* argv[]) {
    5.  
    6. QApplication app(argc, argv);
    7. w.resize(640, 480);
    8. w.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 
    I typed:
    qmake -project //ok
    qmake //ok
    make //errors
    'make' gives me a lot of errors. I suppose they depend from 'bad setting' of qt or other things under LInux.
    Just to give an idea of the problem:
    gcc -c -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I. -o main.o main.c
    In file included from /usr/include/QtCore/qobjectdefs.h:45:0,
    from /usr/include/QtCore/qobject.h:47,
    from /usr/include/QtCore/qcoreapplication.h:45,
    from /usr/include/QtGui/qapplication.h:45,
    from /usr/include/QtGui/QApplication:1,
    from main.c:1:
    /usr/include/QtCore/qnamespace.h: In function ‘QT_MODULE’:
    /usr/include/QtCore/qnamespace.h:54:1: error: unknown type name ‘namespace’
    namespace
    ^
    /usr/include/QtCore/qnamespace.h:58:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or __attribute__’ before ‘{’ token
    Qt {
    ^
    /usr/include/QtCore/qnamespace.h:1799:1: error: expected declaration specifiers before ‘Q_DECLARE_OPERATORS_FOR_FLAGS’
    Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MouseButtons)
    ^
    /usr/include/QtCore/qnamespace.h:1820:1: error: unknown type name ‘class’
    class Q_CORE_EXPORT QInternal {
    ^
    /usr/include/QtCore/qnamespace.h:1820:21: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘QInternal’
    class Q_CORE_EXPORT QInternal {
    ^
    /usr/include/QtCore/qnamespace.h:1875:2: error: expected declaration specifiers before ‘;’ token
    };
    ^
    In file included from /usr/include/QtCore/qobject.h:47:0,
    from /usr/include/QtCore/qcoreapplication.h:45,
    from /usr/include/QtGui/qapplication.h:45,
    from /usr/include/QtGui/QApplication:1,
    from main.c:1:

    [.................................................. .................................................. ................so on.......]
    Does anybody have an idea about the problem?


    Added after 1 34 minutes:


    Hello again,

    I found out to have installed also qmake-qt5. So using it I got a just an error:
    Qt Code:
    1. make
    2. gcc -c -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtCore -I. -I/usr/lib64/qt5/mkspecs/linux-g++ -o main.o main.c
    3. main.c:1:24: fatal error: QApplication: No such file or directory
    4. #include <QApplication>
    5. ^
    6. compilation terminated.
    7. make: *** [main.o] Error 1
    To copy to clipboard, switch view to plain text mode 
    What do you think? Anything is improving?
    Last edited by mickey; 18th July 2016 at 20:59.
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt installation under Linux

    You forgot to post your .pro file.

    Most like it is missing the QT configuration option for widget usage.
    Qt Code:
    1. QT += widgets
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

    P.S.: your application should also have compiled with Qt4

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Qt installation under Linux

    Hello,
    the problem persists; here the output:
    qmake-qt4 -project
    # qmake-qt4
    # make

    /usr/bin/qmake-qt4 -o Makefile ex1.pro
    gcc -c -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I. -o main.o main.c
    In file included from /usr/include/QtCore/qobjectdefs.h:45:0,
    from /usr/include/QtCore/qobject.h:47,
    from /usr/include/QtCore/qcoreapplication.h:45,
    from /usr/include/QtGui/qapplication.h:45,
    from /usr/include/QtGui/QApplication:1,
    from main.c:1:
    /usr/include/QtCore/qnamespace.h: In function ‘QT_MODULE’:
    /usr/include/QtCore/qnamespace.h:54:1: error: unknown type name ‘namespace’
    namespace
    ^
    /usr/include/QtCore/qnamespace.h:58:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
    Qt {
    ^
    /usr/include/QtCore/qnamespace.h:1799:1: error: expected declaration specifiers before ‘Q_DECLARE_OPERATORS_FOR_FLAGS’

    [..............................................so on................................................ .................................]
    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (2.01a) Tue Jul 19 11:24:02 2016
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. TARGET =
    7. DEPENDPATH += .
    8. INCLUDEPATH += .
    9. QT += widgets
    10.  
    11. # Input
    12. SOURCES += main.c
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #include <QApplication>
    2. #include <QWidget>
    3.  
    4. int main(int argc, char* argv[]) {
    5.  
    6. QApplication app(argc, argv);
    7. w.resize(640, 480);
    8. w.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 
    Any further idea?
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt installation under Linux

    That .pro file is for Qt5 now ("widgets" was implied in Qt4 and did not exist as a separate module).

    However, you main problem is that you called your C++ file "main.c".
    So the build system treats it as a C file and tries to compile with the C compiler. which, obviously, doesn't understand C++.

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    mickey (19th July 2016)

Similar Threads

  1. installation error on suse-linux
    By cactus0830 in forum Newbie
    Replies: 2
    Last Post: 9th December 2013, 07:14
  2. Installation Issues in linux
    By valgaba in forum Qt Programming
    Replies: 9
    Last Post: 10th October 2013, 11:30
  3. Qt installation in Linux
    By lindalin in forum Installation and Deployment
    Replies: 4
    Last Post: 11th October 2010, 11:52
  4. Qt-4.4.0 installation error in linux
    By babu198649 in forum Installation and Deployment
    Replies: 4
    Last Post: 27th May 2008, 14:35
  5. installation of qt4.2: linux
    By Jim Peterson in forum Installation and Deployment
    Replies: 7
    Last Post: 2nd March 2007, 18:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.