Results 1 to 9 of 9

Thread: Newbie in OpenGL programming: Program starts and close immediately.

  1. #1
    Join Date
    Mar 2015
    Posts
    105
    Thanks
    50

    Default Newbie in OpenGL programming: Program starts and close immediately.

    Hello!

    I'm using Arch Linux with QtCreator 3.4.2 Based on Qt 5.5.0 (GCC 5.1.0, 64 bit). So, i want to learn about OpenGL programming. To do that i installed "freeglut, mesa, mesa-demos, mesa-libgl, openal, glew". I tried make a program to show me an OpenGL example using QtCreator, but the program starts and close immediately, i don't see nothing and QtCreator doesn't show my any errot message but:
    Starting /home/rob/Programming/C-C++/Linux/Qt/build-Test-Desktop-Debug/Test...
    The program has unexpectedly finished.
    /home/rob/Programming/C-C++/Linux/Qt/build-Test-Desktop-Debug/Test crashed
    Here my code:
    Test.pro
    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2015-08-18T11:40:04
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui opengl
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = Test
    12. TEMPLATE = app
    13.  
    14.  
    15. SOURCES += main.cpp\
    16. mainwindow.cpp \
    17. glwidget.cpp
    18.  
    19. HEADERS += mainwindow.h \
    20. glwidget.h
    21.  
    22. FORMS += mainwindow.ui
    23.  
    24. LIBS += -lglut
    To copy to clipboard, switch view to plain text mode 

    glwidget.h
    Qt Code:
    1. #ifndef GLWIDGET_H
    2. #define GLWIDGET_H
    3.  
    4. #include <QGLWidget>
    5. #include <QObject>
    6.  
    7. class GLWidget : public QGLWidget {
    8. Q_OBJECT
    9.  
    10. public:
    11. explicit GLWidget(QWidget *parent = 0);
    12.  
    13. void initializeGL( );
    14. void paintGL( );
    15. void resizeGL(int w, int h);
    16. };
    17.  
    18. #endif // GLWIDGET_H
    To copy to clipboard, switch view to plain text mode 

    mainwindow.h
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5.  
    6. namespace Ui {
    7. class MainWindow;
    8. }
    9.  
    10. class MainWindow : public QMainWindow
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. explicit MainWindow(QWidget *parent = 0);
    16. ~MainWindow();
    17.  
    18. private slots:
    19. void on_pushButton_clicked();
    20.  
    21. private:
    22. Ui::MainWindow *ui;
    23. };
    24.  
    25. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    glwidget.cpp
    Qt Code:
    1. #include "glwidget.h"
    2. #include "GL/glut.h"
    3.  
    4. GLWidget::GLWidget(QWidget *parent) {
    5.  
    6. }
    7.  
    8. void GLWidget::initializeGL( ) {
    9. glClearColor(0.2, 0.2, 0.2, 1);
    10. }
    11.  
    12. void GLWidget::paintGL( ) {
    13. glClear( GL_COLOR_BUFFER_BIT );
    14. glRotatef(0.5, 1, 1, 1);
    15. glutWireTeapot( 0.6 );
    16. }
    17.  
    18. void GLWidget::resizeGL(int w, int h) {
    19.  
    20. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "GL/glut.h"
    3. #include <QApplication>
    4.  
    5. int main(int argc, char *argv[]) {
    6. glutInit(&argc, argv);
    7. QApplication a(argc, argv);
    8. MainWindow w;
    9. w.show( );
    10.  
    11. return a.exec( );
    12. }
    To copy to clipboard, switch view to plain text mode 

    mainwindow.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) : QMainWindow( parent ), ui(new Ui::MainWindow) {
    5. ui->setupUi( this );
    6. }
    7.  
    8. MainWindow::~MainWindow( ) {
    9. delete ui;
    10. }
    11.  
    12. void MainWindow::on_pushButton_clicked( ) {
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 

    How can i fix it?

  2. #2
    Join Date
    Mar 2015
    Posts
    105
    Thanks
    50

    Default Re: Newbie in OpenGL programming: Program starts and close immediately.

    Sorry bump this thread, but i need help.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie in OpenGL programming: Program starts and close immediately.

    Show us a debugger backtrace for your program.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Mar 2015
    Posts
    105
    Thanks
    50

    Default Re: Newbie in OpenGL programming: Program starts and close immediately.

    One more thing i saw now.

    I launched the software using terminal and i got this:
    > cd Programming/C-C++/Linux/Qt/build-OpenglTest-Desktop-Debug/
    > ./OpenglTest
    Segmentation fault (core dumped)

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie in OpenGL programming: Program starts and close immediately.

    Please show us the backtrace.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Mar 2015
    Posts
    105
    Thanks
    50

    Default Re: Newbie in OpenGL programming: Program starts and close immediately.

    I don't know if i did right.

    Qt Code:
    1. > cd Programming/C-C++/Linux/Qt/build-Test-Desktop-Debug/
    2. > gdb Test
    3. GNU gdb (GDB) 7.9.1
    4. Copyright (C) 2015 Free Software Foundation, Inc.
    5. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    6. This is free software: you are free to change and redistribute it.
    7. There is NO WARRANTY, to the extent permitted by law. Type "show copying"
    8. and "show warranty" for details.
    9. This GDB was configured as "x86_64-unknown-linux-gnu".
    10. Type "show configuration" for configuration details.
    11. For bug reporting instructions, please see:
    12. <http://www.gnu.org/software/gdb/bugs/>.
    13. Find the GDB manual and other documentation resources online at:
    14. <http://www.gnu.org/software/gdb/documentation/>.
    15. For help, type "help".
    16. Type "apropos word" to search for commands related to "word"...
    17. Reading symbols from Test...done.
    18. (gdb) start
    19. Temporary breakpoint 1 at 0x4038e6: file ../Test/main.cpp, line 6.
    20. Starting program: /media/Backup/Programming/C-C++/Linux/Qt/build-Test-Desktop-Debug/Test
    21. [Thread debugging using libthread_db enabled]
    22. Using host libthread_db library "/usr/lib/libthread_db.so.1".
    23.  
    24. Temporary breakpoint 1, main (argc=1, argv=0x7fffffffeac8) at ../Test/main.cpp:6
    25. 6 glutInit(&argc, argv);
    26. (gdb) bt
    27. #0 main (argc=1, argv=0x7fffffffeac8) at ../Test/main.cpp:6
    To copy to clipboard, switch view to plain text mode 

    Thats all i got.

  7. #7
    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: Newbie in OpenGL programming: Program starts and close immediately.

    Almost

    > gdb Test
    (gdb) run

    Once it crashed

    (gdb) bt full

    Cheers,
    _

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

    robgeek (5th September 2015)

  9. #8
    Join Date
    Mar 2015
    Posts
    105
    Thanks
    50

    Default Re: Newbie in OpenGL programming: Program starts and close immediately.

    Oh, i'm sorry!

    Qt Code:
    1. > gdb Test
    2. GNU gdb (GDB) 7.9.1
    3. Copyright (C) 2015 Free Software Foundation, Inc.
    4. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    5. This is free software: you are free to change and redistribute it.
    6. There is NO WARRANTY, to the extent permitted by law. Type "show copying"
    7. and "show warranty" for details.
    8. This GDB was configured as "x86_64-unknown-linux-gnu".
    9. Type "show configuration" for configuration details.
    10. For bug reporting instructions, please see:
    11. <http://www.gnu.org/software/gdb/bugs/>.
    12. Find the GDB manual and other documentation resources online at:
    13. <http://www.gnu.org/software/gdb/documentation/>.
    14. For help, type "help".
    15. Type "apropos word" to search for commands related to "word"...
    16. Reading symbols from Test...done.
    17.  
    18.  
    19. (gdb) run
    20. Starting program: /media/Backup/Programming/C-C++/Linux/Qt/build-Test-Desktop-Debug/Test
    21. [Thread debugging using libthread_db enabled]
    22. Using host libthread_db library "/usr/lib/libthread_db.so.1".
    23. [New Thread 0x7fffe65dd700 (LWP 2817)]
    24. [New Thread 0x7fffe9444700 (LWP 2815)]
    25.  
    26. Program received signal SIGSEGV, Segmentation fault.
    27. 0x00007ffff7b3cd06 in fghDrawGeometryWire () from /usr/lib/libglut.so.3
    28.  
    29.  
    30. (gdb) bt full
    31. #0 0x00007ffff7b3cd06 in fghDrawGeometryWire () from /usr/lib/libglut.so.3
    32. No symbol table info available.
    33. #1 0x00007ffff7b47a70 in ?? () from /usr/lib/libglut.so.3
    34. No symbol table info available.
    35. #2 0x00007ffff7b48322 in glutWireTeapot () from /usr/lib/libglut.so.3
    36. No symbol table info available.
    37. #3 0x0000000000404809 in GLWidget::paintGL (this=0x6c15a0) at ../Test/glwidget.cpp:15
    38. No locals.
    39. #4 0x00007ffff78e78e4 in QGLWidget::glDraw() () from /usr/lib/libQt5OpenGL.so.5
    40. No symbol table info available.
    41. #5 0x00007ffff78e728d in QGLWidget::paintEvent(QPaintEvent*) ()
    42. from /usr/lib/libQt5OpenGL.so.5
    43. No symbol table info available.
    44. #6 0x00007ffff71cef08 in QWidget::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5
    45. No symbol table info available.
    46. #7 0x00007ffff718c00c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    47. from /usr/lib/libQt5Widgets.so.5
    48. No symbol table info available.
    49. #8 0x00007ffff71914e6 in QApplication::notify(QObject*, QEvent*) ()
    50. from /usr/lib/libQt5Widgets.so.5
    51. No symbol table info available.
    52. #9 0x00007ffff645289b in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
    53. from /usr/lib/libQt5Core.so.5
    54. No symbol table info available.
    55. ---Type <return> to continue, or q <return> to quit---
    56. #10 0x00007ffff71c7b39 in QWidgetPrivate::sendPaintEvent(QRegion const&) ()
    57. from /usr/lib/libQt5Widgets.so.5
    58. No symbol table info available.
    59. #11 0x00007ffff71c8181 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () from /usr/lib/libQt5Widgets.so.5
    60. No symbol table info available.
    61. #12 0x00007ffff7197c02 in QWidgetPrivate::repaint_sys(QRegion const&) ()
    62. from /usr/lib/libQt5Widgets.so.5
    63. No symbol table info available.
    64. #13 0x00007ffff71ebc03 in ?? () from /usr/lib/libQt5Widgets.so.5
    65. No symbol table info available.
    66. #14 0x00007ffff718c00c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    67. from /usr/lib/libQt5Widgets.so.5
    68. No symbol table info available.
    69. #15 0x00007ffff71914e6 in QApplication::notify(QObject*, QEvent*) ()
    70. from /usr/lib/libQt5Widgets.so.5
    71. No symbol table info available.
    72. #16 0x00007ffff645289b in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
    73. from /usr/lib/libQt5Core.so.5
    74. No symbol table info available.
    75. #17 0x00007ffff69b2c7c in QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent*) () from /usr/lib/libQt5Gui.so.5
    76. No symbol table info available.
    77. #18 0x00007ffff69b39fd in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystem---Type <return> to continue, or q <return> to quit---
    78. InterfacePrivate::WindowSystemEvent*) () from /usr/lib/libQt5Gui.so.5
    79. No symbol table info available.
    80. #19 0x00007ffff6998e38 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Gui.so.5
    81. No symbol table info available.
    82. #20 0x00007fffe83fa6b0 in ?? () from /usr/lib/libQt5XcbQpa.so.5
    83. No symbol table info available.
    84. #21 0x00007ffff424a9fd in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
    85. No symbol table info available.
    86. #22 0x00007ffff424ace0 in ?? () from /usr/lib/libglib-2.0.so.0
    87. No symbol table info available.
    88. #23 0x00007ffff424ad8c in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
    89. No symbol table info available.
    90. #24 0x00007ffff64a923f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
    91. No symbol table info available.
    92. #25 0x00007ffff645026a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    93. from /usr/lib/libQt5Core.so.5
    94. No symbol table info available.
    95. #26 0x00007ffff645820c in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5
    96. No symbol table info available.
    97. #27 0x0000000000403934 in main (argc=1, argv=0x7fffffffeac8) at ../Test/main.cpp:11
    98. a = <incomplete type>
    99. w = {<QMainWindow> = {<No data fields>}, static staticMetaObject = {d = {
    100. ---Type <return> to continue, or q <return> to quit---
    101. superdata = 0x7ffff78aeee0 <QMainWindow::staticMetaObject>,
    102. stringdata = 0x404c60 <qt_meta_stringdata_MainWindow>,
    103. data = 0x404ce0 <qt_meta_data_MainWindow>,
    104. static_metacall = 0x40481e <MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}},
    105. ui = 0x6c0ed0}
    To copy to clipboard, switch view to plain text mode 

  10. #9
    Join Date
    Mar 2015
    Posts
    105
    Thanks
    50

    Default Re: Newbie in OpenGL programming: Program starts and close immediately.

    So, guys. What do you think!

Similar Threads

  1. Newbie C++ programming,need help!
    By bestmaster99 in forum General Programming
    Replies: 7
    Last Post: 15th March 2013, 06:11
  2. Replies: 3
    Last Post: 25th September 2011, 18:41
  3. Complete newbie with programming and Qt
    By Jacob in forum Newbie
    Replies: 1
    Last Post: 6th March 2010, 06:26
  4. Segmentation Fault when Program Starts
    By KaptainKarl in forum Newbie
    Replies: 7
    Last Post: 10th September 2009, 08:43
  5. Replies: 3
    Last Post: 22nd February 2007, 14:10

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.