Gtkmm程序编译良好,但崩溃- windows XP

Gtkmm program compiles fine but crashes - windows XP

本文关键字:崩溃 windows XP 程序 编译 Gtkmm      更新时间:2023-10-16

我最近安装了gtkmm (gtkmm-2.4)

当我用g++编译时,我使用来自pkg-config

的以下信息

headerfiles

pkg-config gtkmm-2.4 --cflags

objectfiles

pkg-config gtkmm-2.4 --libs

所以我编译了一个简单的helloworld问题,那就是在屏幕上显示一个窗口…

g++ gtkmm_app2.cpp -o gtkmm_app2 `pkg-config gtkmm-2.4 --cflags --libs`

它编译得很好,但是当我执行程序时它崩溃了。我得到以下信息:

gtkmm_app2.exe[5364]

我不是调试的一个发挥,但当我重定向到Visual Studio的问题似乎指向一个dll文件:

 libglibmm-2.4-1.dll

版本和平台信息

编译器:

GNU C++ Compiler: 3.4.5-20060117-3
GNU C++ Compiler Runtime Library: 4.7.2-1
OS:

 Windows XP Home Edition 2002 (Sevice Pack 3)

所以我的问题:我不知道问题取决于什么?它会是MinGw的版本吗?还是操作系统导致了这个问题?我可以在我的c应用程序上使用GTK3编译和执行而不会出现问题,但在c++上使用gtkmm则不行。有什么解决问题的办法吗?非常有帮助的帮助这个!!

==========================================================================

调用栈

libglibmm-2.4-1.dll!6652ea89() // it points here ..
libglibmm-2.4-1.dll!664de158()  
msvcrt.dll!77c2a52e()   
msvcrt.dll!77c29d60()   
msvcrt.dll!77c24e2f()   
msvcrt.dll!77c24e42()   
libgtkmm-2.4-1.dll!0069004d()   
libgtkmm-2.4-1.dll!005f0073()   

和控制台窗口的输出:它似乎是某种如果堆损坏或分段错误:

'gtkmm_app2.exe': Loaded 'C:cygwinhomeÄgarengtkmm_app2.exe', Binary was not built  with debug information.
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32ntdll.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32kernel32.dll', Cannot find or open the  PDB file
'gtkmm_app2.exe': Loaded 'C:gtkmmbinlibglibmm-2.4-1.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:gtkmmbinlibglib-2.0-0.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:gtkmmbinintl.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32advapi32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32rpcrt4.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32secur32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32msvcrt.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32ole32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32gdi32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32user32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32shell32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32shlwapi.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32ws2_32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32ws2help.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:gtkmmbinlibgmodule-2.0-0.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:gtkmmbinlibgobject-2.0-0.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:gtkmmbinlibgthread-2.0-0.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:gtkmmbinlibsigc-2.0-0.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:gtkmmbinlibgcc_s_sjlj-1.dll', Binary was not built with debug information.
......  
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32lpk.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSWinSxSx86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202comctl32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:WINDOWSsystem32apphelp.dll', Cannot find or open the PDB file
Unhandled exception at 0x6652ea89 in gtkmm_app2.exe: 0xC0000005: Access violation writing location 0x00405068.
First-chance exception at 0x6652ea89 in gtkmm_app2.exe: 0xC0000005: Access violation writing location 0x00405068.
Unhandled exception at 0x6652ea89 in gtkmm_app2.exe: 0xC0000005: Access violation writing location 0x00405068.
First-chance exception at 0x6652ea89 in gtkmm_app2.exe: 0xC0000005: Access violation writing location 0x00405068.
Unhandled exception at 0x6652ea89 in gtkmm_app2.exe: 0xC0000005: Access violation writing location 0x00405068.
First-chance exception at 0x6652ea89 in gtkmm_app2.exe: 0xC0000005: Access violation   writing location 0x00405068.
Unhandled exception at 0x6652ea89 in gtkmm_app2.exe: 0xC0000005: Access violation writing location 0x00405068.
First-chance exception at 0x6652ea89 in gtkmm_app2.exe: 0xC0000005: Access violation writing location 0x00405068.
.......
Unhandled exception at 0x6652ea89 in gtkmm_app2.exe: 0xC0000005: Access violation 
The program '[5596] gtkmm_app2.exe: Native' has exited with code 0 (0x0).

EDIT:我成功地用vc++ (Visual Studio 2010)编译和执行了应用程序,所以它必须是MinGW负责崩溃。但是我真的很想知道是什么原因导致了这个问题以及如何解决它。

EDIT2:在调试支持下重新编译后,我在cygwing terminalwindow中得到了这个信息

C:cygwintmpccIK3N1q.o: In function `main':
C:cygwinhome▒garen/gtkmm_app.cpp:5: undefined reference to `Gtk::Main::Main(int&,  char**&, bool)'
C:cygwinhome▒garen/gtkmm_app.cpp:7: undefined reference to   `Gtk::Window::Window(Gtk::WindowType)'
C:cygwinhome▒garen/gtkmm_app.cpp:9: undefined reference to  `Gtk::Main::run(Gtk::Window&)'
C:cygwinhome▒garen/gtkmm_app.cpp:11: undefined reference to `Gtk::Window::~Window()'
C:cygwinhome▒garen/gtkmm_app.cpp:11: undefined reference to `Gtk::Main::~Main()'
C:cygwinhome▒garen/gtkmm_app.cpp:11: undefined reference to `Gtk::Window::~Window()'
C:cygwinhome▒garen/gtkmm_app.cpp:11: undefined reference to `Gtk::Main::~Main()'
C:cygwintmpccIK3N1q.o: In function `_tcf_0':
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:41: undefined reference to  `Glib::ustring::~ustring()'
C:cygwintmpccIK3N1q.o: In function `_tcf_1':
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:42: undefined reference to  `Glib::ustring::~ustring()'
C:cygwintmpccIK3N1q.o: In function `_tcf_2':
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:43: undefined reference to `Glib::ustring::~ustring()'
C:cygwintmpccIK3N1q.o: In function `_tcf_3':
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:44: undefined reference to `Glib::ustring::~ustring()'
C:cygwintmpccIK3N1q.o: In function `_tcf_4':
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:45: undefined reference to `Glib::ustring::~ustring()'
C:cygwintmpccIK3N1q.o:C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:46: more undefined references to `Glib::ustring::~ustring()' follow
C:cygwintmpccIK3N1q.o: In function `_static_initialization_and_destruction_0':
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:41: undefined reference to  `Glib::ustring::ustring(char const*)'
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:42: undefined reference to `Glib::ustring::ustring(char const*)'
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:43: undefined reference to `Glib::ustring::ustring(char const*)'
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:44: undefined reference to `Glib::ustring::ustring(char const*)'
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:45: undefined reference to `Glib::ustring::ustring(char const*)'
C:cygwintmpccIK3N1q.o:C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:46: more   undefined references to `Glib::ustring::ustring(char const*)' follow
collect2.exe: error: ld returned 1 exit status`

正如我在第一次编辑中提到的,我可以在Visual Studio 2010中使用vc++编译和执行,没有问题。那么问题是什么呢?

现在我看到了调试输出,我相信您的问题是您的编译标志的顺序。我想试试:

g++ -Wall -g `pkg-config --cflags gtkmm-2.4` gtkmm_app2.cpp -o gtkmm_app2 `pkg-config --libs gtkmm-2.4`

语法:

`pkg-config gtkmm-2.4 --cflags --libs`
不应该使用

。它会编译,但不会链接到外部的gtkmm库。

通常mingw和msvc需要单独的二进制文件。如果您使用mingw,则应该使用使用mingw编译的gtkmm。混合编译器不能很好地工作