Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/163.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Gtkmm程序编译良好但崩溃-windows XP_C++_Windows_Mingw_Gtkmm - Fatal编程技术网

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

C++ Gtkmm程序编译良好但崩溃-windows XP,c++,windows,mingw,gtkmm,C++,Windows,Mingw,Gtkmm,我最近安装了gtkmm(gtkmm-2.4) 当我使用g++编译时,我使用pkg config中的以下信息 头饰 对象文件 所以我编译了一个简单的helloworld problam,在屏幕上显示一个窗口 g++ gtkmm_app2.cpp -o gtkmm_app2 `pkg-config gtkmm-2.4 --cflags --libs` 它编译得很好,但当我执行程序时,它会崩溃。我得到以下信息: gtkmm_app2.exe[5364]中发生未经处理的win32异常。 我不是调试高手

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

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

头饰

对象文件

所以我编译了一个简单的helloworld problam,在屏幕上显示一个窗口

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
操作系统:


那么我的问题是:我不知道这些问题取决于什么?可能是MinGw的版本吗?还是操作系统导致了问题?我可以编译和执行没有问题使用GTK3在我的C应用程序,但不是GTKMM与C++。有什么办法解决这个问题吗?非常有帮助的帮助这个

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

调用堆栈

控制台中的和输出窗口:如果heapcorruption或segmentation出现故障,则似乎是某种类型:

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

EDIT2:使用调试支持重新编译后,我在cygwing terminalwindow中获得了此信息

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`

正如我在第一次编辑中提到的,我可以在VisualStudio2010中用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。混合编译器不能很好地工作。

使用调试支持重新编译;让程序崩溃,然后用崩溃的位置/原因更新您的问题
g++-O0-ggdb gtkmm_app2.cpp-o gtkmm_app2'pkg config gtkmm-2.4--cflags--libs'
@Mark-我更新了我的问题:编译gtkmm使用了什么编译器?可能有不同的ABI。我有相同的问题,你能解决吗?我在x86机器上使用gtkmm 2.22和mingw32,这不起作用,但我使用粘贴到语法中的pkg配置输出。我必须这样做,因为cygqin出于某种原因不接受我的论点。它说“无效的论点。我的解决方案不漂亮,但应该是一样的?”?
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).
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`
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`