在嵌入式系统上运行 Qt Helloworld 时出现分段错误 [英] Segmentation fault while running Qt Helloworld on embedded system

查看:38
本文介绍了在嵌入式系统上运行 Qt Helloworld 时出现分段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为 ARM 交叉编译了一个 Helloworld 可执行文件.它在我朋友的开发板上运行良好,但由于我的开发板上出现分段错误"而失败.两块板在硬件和软件上都略有不同.

I cross-compiled a Helloworld executable for ARM. It worked well on my friend's development board, but failed with a " segmentation fault " on my board. The two boards are slightly different in both hardware and software.

我的问题是,如何在我的电路板中进行调试?这么简单的程序调试起来是不是比较容易?这是否表明可执行文件没有任何问题,问题很可能出在我的板子的文件系统中?

My question is, how can I debug in my board? Is it relatively easy to debug such a simple program? Does it indicate that there's nothing wrong with the executable and the problem most probably lies in the filesystem of my board?

代码如下:

#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QPushButton hello("Hello world");
hello.resize(100, 30);

hello.show();
return app.exec();
}

可执行文件由以下命令生成:

And the executable is generated by the following commands:

qmake -project
qmake
make

推荐答案

gdb 很可能被移植到 ARM 目标上运行,但如果缺少该目标或为了便于调试,您应该使用 gdb 远程调试.http://sourceware.org/gdb/onlinedocs/gdb/Remote-Debugging.html#Remote-Debugging

most probably gdb is ported to be run on ARM target but in case lack of that or for easy debugging, you should use gdb remote debugging. http://sourceware.org/gdb/onlinedocs/gdb/Remote-Debugging.html#Remote-Debugging

Gdbserver 是应该在目标上运行的应用程序.下面是如何使用它的演示.(复制自维基百科)

Gdbserver is the application should be run on target. the following is demonstration howto use it. (copied from wikipedia)

目标设置:

remote$ gdbserver :2345 hello_world
Process hello_world created; pid = 2509
Listening on port 2345

主机设置:

local$ gdb -q hello_world
Reading symbols from /home/user/hello_world...done.
(gdb) target remote 192.168.0.11:2345
Remote debugging using 192.168.0.11:2345
0x002f3850 in ?? () from /lib/ld-linux.so.2
(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x08048414 in main () at hello_world.c:10
10              printf("x[%d] = %g\n", i, x[i]);
(gdb) 

这篇关于在嵌入式系统上运行 Qt Helloworld 时出现分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆