-
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..
Code:
int main(int argc, char * argv[])
{
printf("Inside main\n");
printf("object created \n");
Widget w;
w.show();
app.exec();
}
./my
Inside main
Segmentation fault
But I am able to create Object for QCoreApplication
Code:
int main(int argc, char * argv[])
{
printf("Inside main\n");
printf("object created \n");
a.arguments();
a.flush();
}
./my
Inside main
object created
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??
-
Re: Segmentation fault while creating Object for QApplication
are you linking the qtgui library in your project?
-
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.
-
Re: Segmentation fault while creating Object for QApplication
QApplication is in qtgui library.. so you need that...
-
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..
-
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.
-
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??
-
Re: Segmentation fault while creating Object for QApplication
Does your ARM device have an X11 server?
-
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??
-
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?
-
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....
-
Re: Segmentation fault while creating Object for QApplication
-
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.
-
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.
-
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.
-
Re: Segmentation fault while creating Object for QApplication
Do other examples work as well?
-
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..
-
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.
-
1 Attachment(s)
Re: Segmentation fault while creating Object for QApplication
Below is my test application code
main.cpp file
Code:
#include <QtGui/QApplication>
#include <QLabel>
#include "widget.h"
int main(int argc, char *argv[])
{
printf("Inside main\n");
unsigned int loop;
printf("argc = %d \n",argc);
for(loop=0;loop<argc;loop++)
{
printf("argv[%d] = %s \n",argc,argv[loop]);
}
Widget w;
w.setFixedSize(200,200);
w.show();
return a.exec();
}
[B][U]widget.cpp file[/U][/B]
#include "widget.h"
{
}
Widget::~Widget()
{
}
[U][B]widget.h file[/B][/U]
#ifndef WIDGET_H
#define WIDGET_H
#include <QtGui/QWidget>
{
Q_OBJECT
public:
~Widget();
};
#endif // WIDGET_H
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..
-
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.
-
Re: Segmentation fault while creating Object for QApplication
Can you post result for the following command "fbset --info" too, thx.
-
Re: Segmentation fault while creating Object for QApplication
Hi,
I am trying something similar on a an embedded system, albeit a different one.
How was this resolved, if at all?
I know that this thread is dated, but anything that can be recalled will be helpful.
Cheers,
--
Vis