【问题标题】:Hello world program crashes in gtkmmHello world 程序在 gtkmm 中崩溃
【发布时间】:2012-07-11 14:02:44
【问题描述】:

我正在尝试让 gtkmm 使用 MinGW 在 Windows 7 上工作。但是,当我从 gtkmm-tutorial 编译 hello world 程序后,exe 会因段错误而崩溃。

我已经用这个编译了程序:

$ g++ helloworld.cc main.cc -o hw `pkg-config --cflags --libs gtkmm-2.4`

gdb 显示如下:

$ gdb hw.exe
GNU gdb (GDB) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from c:\dev/hw.exe...done.
(gdb) run
Starting program: c:\dev/hw.exe
[New Thread 4348.0x1560]
[New Thread 4348.0x1430]

Program received signal SIGSEGV, Segmentation fault.
0x664d85b2 in Glib::ObjectBase::ObjectBase (this=0x47453c, __vtt_parm=0x1,
    __in_chrg=<value optimized out>) at objectbase.cc:49
49      objectbase.cc: No such file or directory.

我有点新手,所以我不知道如何让它工作。

我已经从here(2.22版本)和g++的版本下载了gtkmm:

$ g++ -v
Using built-in specs.
COLLECT_GCC=c:\Mingw\bin\g++.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.7.1/lto-wrappe
r.exe
Target: i686-pc-mingw32
Configured with: ../src/configure --prefix=/c/temp/gcc/dest --with-gmp=/c/temp/g
cc/gmp --with-mpfr=/c/temp/gcc/mpfr --with-mpc=/c/temp/gcc/mpc --enable-language
s=c,c++ --with-arch=i686 --with-tune=generic --disable-libstdcxx-pch --disable-n
ls --disable-shared --disable-sjlj-exceptions --disable-win32-registry --enable-
checking=release --enable-lto
Thread model: win32
gcc version 4.7.1 (GCC)

我还需要更多吗?还是我做错了?

【问题讨论】:

  • 您需要在 GDB 中发出 bt 命令 (BackTrace) 在段错误之后,找出您的代码的哪一行触发了它。另外,您是复制粘贴程序还是自己输入的?

标签: c++ windows-7 mingw gtkmm


【解决方案1】:

似乎是 MinGW made an ABI change with GCC 4.7.0。如果您的 gtkmm 是使用较早的 GCC 编译的,则会导致您看到的问题。尝试使用相同的编译器重建 gtkmm。

【讨论】:

  • 好的,这意味着我需要编译 GTK+、giomm 和 pangomm。我需要一些时间来编译这些库,因为我没有太多时间让它们工作。感谢您的回答。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-30
  • 1970-01-01
  • 1970-01-01
  • 2018-08-06
  • 2011-07-07
  • 1970-01-01
相关资源
最近更新 更多