1

问题:我有一个 C++ Qt 项目,它在我点击“运行”时运行,在我手动执行输出可执行文件时运行,但不会在 NetBeans 中使用 GDB 运行。在 NetBeans 中单击“调试主项目”后,我收到消息“在启动程序期间退出,代码为 0xc0000135”。

我有调试器日志:

=thread-group-added,id="i1"
~"GNU gdb (GDB) 7.4\n"
~"Copyright (C) 2012 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
~"This GDB was configured as \"i686-pc-mingw32\".\nFor bug reporting instructions, please see:\n"
~"<http://www.gnu.org/software/gdb/bugs/>.\n"
&"C:\\\\Users\\\\Rafael Andreatta/.gdbinit: No such file or directory.\n"
(gdb) 
2-list-features
3-gdb-set print repeat 0
4-gdb-set backtrace limit 1024
5-gdb-set print elements 0
6-file-symbol-file "B:/Dropbox/Projects/rafaame/FileSync/dist/Debug/MinGW-Windows/FileSync"
7-file-exec-and-symbols  "B:\\Dropbox\\Projects\\rafaame\\FileSync\\dist\\Debug\\MinGW-Windows\\FileSync"
2^done,features=["frozen-varobjs","pending-breakpoints","thread-info","data-read-memory-bytes","breakpoint-notifications","ada-task-info"]
(gdb) 
3^done
(gdb) 
4^done
(gdb) 
5^done
(gdb) 
6^done
(gdb) 
7^done
(gdb) 
8-file-list-exec-source-file
9cd B:\Dropbox\Projects\rafaame\FileSync
10-exec-arguments 
11set environment Path=B:\Synced\Applications\Development\Cygwin\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;B:\Synced\Applications\Development\Cygwin\bin;B:\Synced\Applications\Development\SDKs\jdk1.7.0_03\bin;B:\Synced\Applications\Development\SDKs\QtSDK\Desktop\Qt\4.8.0\mingw\bin;B:\Synced\Applications\Development\Clients\PrivateShell;
12-break-insert -f "B:/Dropbox/Projects/rafaame/FileSync/DebugHandler.cpp:29"
8^done,line="21",file="../mingw/main.c",macro-info="0"
(gdb) 
13-break-insert -t _start
&"cd B:\\Dropbox\\Projects\\rafaame\\FileSync\n"
~"Working directory B:\\Dropbox\\Projects\\rafaame\\FileSync.\n"
9^done
(gdb) 
10^done
(gdb) 
&"set environment Path=B:\\Synced\\Applications\\Development\\Cygwin\\bin;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;B:\\Synced\\Applications\\Development\\Cygwin\\bin;B:\\Synced\\Applications\\Development\\SDKs\\jdk1.7.0_03\\bin;B:\\Synced\\Applications\\Development\\SDKs\\QtSDK\\Desktop\\Qt\\4.8.0\\mingw\\bin;B:\\Synced\\Applications\\Development\\Clients\\PrivateShell;\n"
11^done
(gdb) 
12^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00403fcb",func="DebugHandler::messageOutputLog(QtMsgType, char const*)",file="DebugHandler.cpp",fullname="B:\\Dropbox\\Projects\\rafaame\\FileSync\\DebugHandler.cpp",line="29",times="0",original-location="B:/Dropbox/Projects/rafaame/FileSync/DebugHandler.cpp:29"}
(gdb) 
13^error,msg="Function \"_start\" not defined."
(gdb) 
14-break-insert -t main
14^done,bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x00404ab4",func="main",file="../mingw/main.c",line="30",times="0",original-location="main"}
(gdb) 
15-exec-run
&"warning: Warning: Failed to open TTY /dev/pty0, error 0x3.\n"
=thread-group-started,id="i1",pid="3928"
=thread-created,id="1",group-id="i1"
~"[New Thread 3928.0x27d8]\n"
15^running
*running,thread-id="all"
(gdb) 
=thread-exited,id="1",group-id="i1"
=thread-group-exited,id="i1"
15^error,msg="During startup program exited with code 0xc0000135."
(gdb) 

Windows 中的 PATH 环境变量是

C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;
%SystemRoot%;
%SystemRoot%\System32\Wbem;
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
B:\Synced\Applications\Development\SDKs\jdk1.7.0_03\bin;
B:\Synced\Applications\Development\SDKs\QtSDK\Desktop\Qt\4.8.0\mingw\bin;
B:\Synced\Applications\Development\Clients\PrivateShell;
B:\Synced\Applications\Development\MinGW\bin

有没有人有同样的问题并修复?

谢谢大家的帮助

4

1 回答 1

2

我很长时间没有接触 C++,但我今天遇到了类似的问题。事实证明,有些库没有与可执行文件链接。我通过添加来修复它

-static-libgcc -static-libstdc++

到编译器选项(Makefile 中的 CXXFLAGS)

于 2012-07-12T08:24:57.107 回答