c++ - Gtkmm 程序编译正常但崩溃 - Windows XP

标签 c++ windows mingw gtkmm

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

当我用 g++ 编译时,我使用 pkg-config 中的以下信息

头文件

pkg-config gtkmm-2.4 --cflags

目标文件

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] 中发生未处理的 win32 异常

我不擅长调试,但当我被重定向到 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

操作系统:

 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:\cygwin\home\Ägaren\gtkmm_app2.exe', Binary was not built  with debug information.
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the  PDB file
'gtkmm_app2.exe': Loaded 'C:\gtkmm\bin\libglibmm-2.4-1.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:\gtkmm\bin\libglib-2.0-0.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:\gtkmm\bin\intl.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\user32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\ws2_32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\gtkmm\bin\libgmodule-2.0-0.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:\gtkmm\bin\libgobject-2.0-0.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:\gtkmm\bin\libgthread-2.0-0.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:\gtkmm\bin\libsigc-2.0-0.dll', Binary was not built with debug information.
'gtkmm_app2.exe': Loaded 'C:\gtkmm\bin\libgcc_s_sjlj-1.dll', Binary was not built with debug information.

......  
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\lpk.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202\comctl32.dll', Cannot find or open the PDB file
'gtkmm_app2.exe': Loaded 'C:\WINDOWS\system32\apphelp.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).

编辑:我成功地使用 VC++ (Visual Studio 2010) 编译并执行了该应用程序,因此一定是 MinGW 对崩溃负责。但我真的很想知道是什么导致了这个问题以及如何解决它。

EDIT2:在使用调试支持重新编译后,我在 cygwing 终端窗口中得到了这个信息

C:\cygwin\tmp\ccIK3N1q.o: In function `main':
C:\cygwin\home\▒garen/gtkmm_app.cpp:5: undefined reference to `Gtk::Main::Main(int&,  char**&, bool)'
C:\cygwin\home\▒garen/gtkmm_app.cpp:7: undefined reference to   `Gtk::Window::Window(Gtk::WindowType)'
C:\cygwin\home\▒garen/gtkmm_app.cpp:9: undefined reference to  `Gtk::Main::run(Gtk::Window&)'
C:\cygwin\home\▒garen/gtkmm_app.cpp:11: undefined reference to `Gtk::Window::~Window()'
C:\cygwin\home\▒garen/gtkmm_app.cpp:11: undefined reference to `Gtk::Main::~Main()'
C:\cygwin\home\▒garen/gtkmm_app.cpp:11: undefined reference to `Gtk::Window::~Window()'
C:\cygwin\home\▒garen/gtkmm_app.cpp:11: undefined reference to `Gtk::Main::~Main()'
C:\cygwin\tmp\ccIK3N1q.o: In function `_tcf_0':
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:41: undefined reference to  `Glib::ustring::~ustring()'
C:\cygwin\tmp\ccIK3N1q.o: In function `_tcf_1':
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:42: undefined reference to  `Glib::ustring::~ustring()'
C:\cygwin\tmp\ccIK3N1q.o: In function `_tcf_2':
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:43: undefined reference to `Glib::ustring::~ustring()'
C:\cygwin\tmp\ccIK3N1q.o: In function `_tcf_3':
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:44: undefined reference to `Glib::ustring::~ustring()'
C:\cygwin\tmp\ccIK3N1q.o: In function `_tcf_4':
C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:45: undefined reference to `Glib::ustring::~ustring()'
C:\cygwin\tmp\ccIK3N1q.o:C:/gtkmm/include/gtkmm-2.4/gtkmm/papersize.h:46: more undefined references to `Glib::ustring::~ustring()' follow
C:\cygwin\tmp\ccIK3N1q.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:\cygwin\tmp\ccIK3N1q.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 库。

关于c++ - Gtkmm 程序编译正常但崩溃 - Windows XP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23970603/

相关文章:

java - 启动 Stardog 服务器时出错

c++ - 如何编译和运行在 Windows 10 上使用 libev 的示例程序

c++ - 我可以在 Armadillo 中实例化矩阵,然后在后面的代码行中将其设置为使用辅助内存吗?

python - 如何让 Jupyter Notebook 在系统变量中使用 PYTHONPATH 而无需直接破解 sys.path?

visual-c++ - C/C++ 编译器 (Windows)

c++ - #pragma pack(16) 和#pragma pack(8) 的效果总是一样吗?

c++ - c++如何将6e(或带e的任何数字)解释为输入?

c++ - 使用迭代器将数组分成大小不等的部分

C++ getter/setter 编码风格

c++ - 将 Unix 可执行文件转换为 Windows 可执行文件