问题
When i want to run a program with arguments out of the IDE i do this: ProjectProperties→Run→Arguments and type my arguments in there.
But if I want to Debug, NetBeans ignores these arguments given there.
So how can I debug a project with command-line-arguments given?
回答1:
I had the same issue.. My NetBeans C project don't take command line arguments in debug mode.., but only with run (F6).. .. What I've done (NetBeans/MinGW): uninstall mingw-get run mingw-get-inst-20100909.exe (this has gdb 7.1). http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/mingw-get-inst-20100909/ This is a temporarry solution until binary NetBeans 6.9.2 release will be available.. Hope this help someone..
回答2:
I had the same issue with Netbeans 6.9
but not 6.8
, and found that the solution was to update Netbeans
.
http://forums.netbeans.org/topic36082.html
回答3:
I have the same issue, and there is a way to get around it.
First, you need to enable GDB console within NetBeans, by setting this options on your netbeans config file (you will have to close NetBeans for it to work)
-J-Dgdb.console.window=true
Next, on NetBeans and before you start your program, set a break point right at the start of your main(). Once execution breaks there, use the "set args [arguments]" gdb command followed by "run" to restart your debugged program, now with the arguments set.
You do not need to close the debug session when you rebuild your project, as GDB will detect it and reload the new binary when you issue the "run" command again; this way you wont have to set the arguments again.
来源:https://stackoverflow.com/questions/4353764/c-netbeans-run-configuration-passing-arguments-issue