Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: Segmentation fault while creating Object for QApplication

  1. #1
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Exclamation Segmentation fault while creating Object for QApplication

    I have been using qt for embedded linux 4.5 on Embedded(arm) platform. While running simple qt application I got segmentation fault. I traced out and found that while creating object for QApplication its shows segmentation fault.(I have installed shared Lib at right location)
    Below is my code..
    Qt Code:
    1. int main(int argc, char * argv[])
    2. {
    3. printf("Inside main\n");
    4. [B]QApplication app(argc, argv);[/B] // Got error here
    5. printf("object created \n");
    6. Widget w;
    7. w.show();
    8. app.exec();
    9.  
    10. }
    11.  
    12. ./my
    13. Inside main
    14. Segmentation fault
    To copy to clipboard, switch view to plain text mode 

    But I am able to create Object for QCoreApplication

    Qt Code:
    1. int main(int argc, char * argv[])
    2. {
    3. printf("Inside main\n");
    4. [B]QCoreApplication app(argc, argv);[/B]
    5. printf("object created \n");
    6. a.arguments();
    7. a.flush();
    8.  
    9. }
    10.  
    11. ./my
    12. Inside main
    13. object created
    To copy to clipboard, switch view to plain text mode 

    I don't understand why its not creating object for QApplication??
    What is going wrong??
    I am not able to find the reason, can anybody help me out??

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Segmentation fault while creating Object for QApplication

    are you linking the qtgui library in your project?

  3. #3
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Segmentation fault while creating Object for QApplication

    no I am not linking qtgui library in my project. Is it required ??
    I have cross compiled and placed the qt library in my file system. when i run its getting the shared Library information from that lib. I have copied core.so qui.so and network.so files.

    You suggestion would be a great help for me.

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Segmentation fault while creating Object for QApplication

    QApplication is in qtgui library.. so you need that...

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

    nrabara (25th August 2009)

  6. #5
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Segmentation fault while creating Object for QApplication

    Mr Death, I am using arm-linux-gcc for cross compiling and its support rpath, so i dont need to set LD_LIBRARY_PATH ??
    When i run qt application its able to get shared lib info....
    but show segmentation fault while creating QApplication object....

    if it dont get the shared lib info, it wont create QCoreApplication object also..

    I am wrong? or missing something ??

    your suggestion would be great help for me..

  7. #6
    Join Date
    Dec 2008
    Location
    France
    Posts
    93
    Thanked 23 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Segmentation fault while creating Object for QApplication

    Hi,

    If you program crash when you try to use QApplication, it can be because you don't have the appropriate lib in your target.

    Qt works with modules, GUI module and Core module are two of them.

    QCoreApplication is part of the Core module (you need the libQtCore.so in your target).
    QApplication is part of the GUI module ( you need the libQtGui.so in your target).
    Of course you can check for dependency with ldd command.

    QApplication is for app with GUI.
    QCoreApplication if for app without GUI.

    So, use the one that fit for your project.

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

    nrabara (25th August 2009)

  9. #7
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Segmentation fault while creating Object for QApplication

    I have installed libQtGui.so , libQtCore.so and libQtNetwork.so files in my target board.

    I have back traced with arm-linux-strace utility, its showing segmentation fault while trying to mmap() for fb0.;.
    It not a problem with directory path... I have traced out that qt application is able to find libQtGui.so , libQtCore.so and libQtNetwork.so.

    my
    libQtGui.so = 11 MB
    libQtCore.so = 3.2 MB and
    libQtNetwork.so = 1.1 MB

    I have 32 MB of FLASH and 32MB SDRAM. whether it's problem with memory??

  10. #8
    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: Segmentation fault while creating Object for QApplication

    Does your ARM device have an X11 server?
    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.


  11. #9
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Segmentation fault while creating Object for QApplication

    No on my ARM i don't have X11.
    I have connected TFT 640*480 and run qt framebuffer test program, Its shows me 3 rectangles on TFT so framebuffer fb0 is working correctly.
    Is X11 is required??

  12. #10
    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: Segmentation fault while creating Object for QApplication

    It's not required but you probably have to somehow tell QApplication not to try to connect to X server With Qtopia you would use QtopiaApplication but with bare Qt/Embedded you probably need to use QApplication. You did compile Qt/Embedded for your device, right? You didn't just cross-compile the desktop edition for ARM?
    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.


  13. The following user says thank you to wysota for this useful post:

    nrabara (25th August 2009)

  14. #11
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Segmentation fault while creating Object for QApplication

    I do remember that i have used qt-embedded-linux-open-source-4.5.
    I am getting following message when i try to run qt application.

    # ./JS
    QWSSocket::connectToLocalFile could not connect :: Connection refused
    No Qt for embedded linux server appears to be running
    If you want to run the program as a server
    add -qws

    when I run with # ./JS -qws
    Segmentation fault

    any suggestion would be appreciable....

  15. #12
    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: Segmentation fault while creating Object for QApplication

    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.


  16. #13
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Segmentation fault while creating Object for QApplication

    Yes I have read it,

    I have used following..
    export QT_DIR=/home/qt
    export LD_LIBRARY_PATH=$QT_DIR/lib
    export QWD_DISPLAY=LinuxFb

    I have intalled libQtGui.so.4 , libQtCore.so.4 ,libQtNetwork.so.4 in my board at /home/qt/lib.(same path user while cross compiling with arm-linux-gcc)
    I have also intalled fonts to /home/qt/fonts
    i have place qmake in /usr/bin or my board

    I dont under understand why it's(segmentation fault) happening with QApplication only why not with QCoreApplicaton.

    Your suggestion would be a great help for me.

  17. #14
    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: Segmentation fault while creating Object for QApplication

    Does the user have access rights to write to the framebuffer?

    QCoreApplication works because the application doesn't try to access the framebuffer.
    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.


  18. #15
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Segmentation fault while creating Object for QApplication

    Yes user have rights to access /dev/fb0
    Even I can run qt example code of frambuffer(examples/qws/framebuffer.) on board, and Its show me three rectangles on my display.

  19. #16
    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: Segmentation fault while creating Object for QApplication

    Do other examples work as well?
    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.


  20. #17
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Segmentation fault while creating Object for QApplication

    All the example having QApplication object show segmentation fault.

    But for QCoreApplication object, i can use QDateTime, QDate etc.. sub classes of QCoreApplication. It's works fine with QCoreApplication.

    Is there any other way to test QApplication object, I mean
    Can ./configure affect Qt Gui ?? I have tried with full configuration also.

    Your suggestion would be great help for me..

  21. #18
    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: Segmentation fault while creating Object for QApplication

    Your problem is deployment, not compilation. Could you post a backtrace of an exemplory crash? An strace showing files being opened (and statuses of the calls) would be nice as well.
    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.


  22. #19
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Segmentation fault while creating Object for QApplication

    Below is my test application code

    main.cpp file

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QLabel>
    3. #include "widget.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. printf("Inside main\n");
    8. unsigned int loop;
    9. QApplication a(argc, argv);
    10. printf("argc = %d \n",argc);
    11. for(loop=0;loop<argc;loop++)
    12. {
    13. printf("argv[%d] = %s \n",argc,argv[loop]);
    14. }
    15. Widget w;
    16. w.setFixedSize(200,200);
    17. w.show();
    18. return a.exec();
    19. }
    20.  
    21. [B][U]widget.cpp file[/U][/B]
    22.  
    23. #include "widget.h"
    24.  
    25. Widget::Widget(QWidget *parent)
    26. : QWidget(parent)
    27. {
    28. }
    29.  
    30. Widget::~Widget()
    31. {
    32.  
    33. }
    34.  
    35. [U][B]widget.h file[/B][/U]
    36.  
    37. #ifndef WIDGET_H
    38. #define WIDGET_H
    39.  
    40. #include <QtGui/QWidget>
    41.  
    42. class Widget : public QWidget
    43. {
    44. Q_OBJECT
    45.  
    46. public:
    47. Widget(QWidget *parent = 0);
    48. ~Widget();
    49. };
    50.  
    51. #endif // WIDGET_H
    To copy to clipboard, switch view to plain text mode 

    Back trace of the above code is attached - file : QApplication_backtrace.txt

    I have also attached back trace of qt's example code - framebuffer , file : QtFramebuffer_exampleCode.txt

    Your suggestion would be a great help for me..
    Attached Files Attached Files

  23. #20
    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: Segmentation fault while creating Object for QApplication

    This is an strace. What about a debugger backtrace?

    The strace suggests there is a problem with mapping the framebuffer to memory.
    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.


Similar Threads

  1. Replies: 2
    Last Post: 16th June 2010, 23:58
  2. segmentation fault for no apparent reason
    By rishiraj in forum Newbie
    Replies: 1
    Last Post: 12th February 2009, 11:13
  3. segmentation fault
    By uchennaanyanwu in forum Newbie
    Replies: 3
    Last Post: 31st July 2008, 16:52
  4. Segmentation fault running any QT4 executables
    By jellis in forum Installation and Deployment
    Replies: 7
    Last Post: 19th May 2007, 16:35
  5. Icons missing => segmentation fault
    By antonio.r.tome in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 16:30

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.