gdb fails with error 193 when debugging MinGW-compiled code
Solution 1
Could it be that either you are using an older version of gdb, that doesn't support native MinGW debugging (unlikely since you said you updated to the latest version), or you are invoking the debugger incorrectly? In other words, if your executable is named helloworld.exe
, gdb helloworld
may give you that error, whereas gdb helloworld.exe
may work.
Edit: further googling says that trying a directory name without spaces might work (the solution is for Code::Blocks, but it doesn't hurt to try).
Solution 2
Google tells me that "Error 193" is a Windows error code that means an executable is not, in fact, executable. Looks like there's something wrong with your EXE - can you start it directly?
Solution 3
your shared library setting got turned on (probably because you switched your project from an executable to a shared library, then back) and gcc is still being called with the '-shared' options, but the output file has the .exe extension. There is a checkbox called 'shared' in
Properties => C/C++ Build => Settings => Tool Settings => MinGW C Linker => Shared Library Settings.
Make sure it's not checked. I had also error 193 until I flipped this off.
Pieter
Updated on June 10, 2022Comments
-
Pieter almost 2 years
This is shown when I try to debug my code with Eclipse:
I then tried creating a simple Hello World program manually with Notepad++ and the command-line
gcc
. When I launched the gdb debugger this happened:(gdb) run
Starting program: C:\Documents and Settings\Pieter\Bureaublad/test.exe Error creating process C:\Documents and Settings\Pieter\Bureaublad/test.exe, (error 193).
The binary runs fine, but as soon as I try to debug it error 193 is returned. I'm working with C code that is processed by the MinGW GCC compiler. I tried reinstalling both the compiler and the debugger (latest versions) but that didn't change anything. It has worked in the past, and I do not remember making any changes to settings related to the compiler.
Here's an example of an error log as it was generated by Eclipse.
!ENTRY org.eclipse.cdt.dsf.gdb 4 5012 2010-02-09 18:19:47.375 !MESSAGE Error in final launch sequence !STACK 1 org.eclipse.core.runtime.CoreException: Failed to execute MI command: -exec-run Error message from debugger back end: Error creating process C:/Documents and Settings/Pieter/Mijn documenten/My Dropbox/Unief/C/H12/Opdr07/Debug/CH12O07.exe, (error 193). at org.eclipse.cdt.dsf.concurrent.Sequence.abortExecution(Sequence.java:560) at org.eclipse.cdt.dsf.concurrent.Sequence.access$4(Sequence.java:552) at org.eclipse.cdt.dsf.concurrent.Sequence$2.handleErrorOrWarning(Sequence.java:424) at org.eclipse.cdt.dsf.concurrent.RequestMonitor.handleFailure(RequestMonitor.java:314) at org.eclipse.cdt.dsf.concurrent.RequestMonitor.handleCompleted(RequestMonitor.java:277) at org.eclipse.cdt.dsf.concurrent.RequestMonitor$2.run(RequestMonitor.java:239) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) !SUBENTRY 1 org.eclipse.cdt.dsf.gdb 4 10004 2010-02-09 18:19:47.546 !MESSAGE Failed to execute MI command: -exec-run Error message from debugger back end: Error creating process C:/Documents and Settings/Pieter/Mijn documenten/My Dropbox/Unief/C/H12/Opdr07/Debug/CH12O07.exe, (error 193).
-
Pieter over 14 yearsI can start it directly, but I need to debug it since it crashes.
-
Michael Borgwardt over 14 years@Pieter: I've found a thread in a German C++ forum descrbing the same problem: c-plusplus.de/forum/viewtopic-var-t-is-229700.html - It doesn't seem to offer a clear-cut solution (in a linked-to thread, someone got gdb to work only after using subst to put the executable on its own drive), but it looks like you're Dutch, so perhaps it can give you some hints.
-
Pieter over 14 yearsAre they suggesting that I run Cygwin to build a Linux binary instead of a Windows binary?
-
Michael Borgwardt over 14 yearsCygwin seems to have been the key in that case, but of course it would still build Windows binaries.
-
Pieter over 14 yearsYikes. That's a frustrating workaround. I'll keep this question opened for another while just in case there are easier solutions.
-
Pieter over 14 yearsI've tried several versions of gdb, all were >= 7.0. The version I used before the problems started occurring is GDB-7.0.50.20100202. I don't use Cygwin to compile my projects, although I've tried but Eclipse didn't detect it. The compiler I use is MinGW GCC.
-
VonC over 14 years@Pieter Could you try using cygwin though, to check if the problem persist in that environment? For CDT + cygwin, you can try and follow blog.genius-field.com/2009/04/20/… (or homepage.cs.uri.edu/courses/fall2007/csc406/Handouts/…). Check also old.nabble.com/cygwin-toolchain-unsupported--td15180630.html and dreamlayers.blogspot.com/2010/01/…
-
VonC over 14 yearsCheck also dev.eclipse.org/mhonarc/lists/cdt-dev/msg16936.html for issue with "gcc.exe" in new Cygwin (1.7).
-
Pieter over 14 yearsI put Cygwin's bin folder in the path, but Eclipse still isn't detecting Cygwin. I made sure I restarted Eclipse after Cygwin installed and I did check gcc, gcc-core and make.
-
Pieter over 14 yearsWhere do I put my etc directory (C:\cygwin\etc) in "HKCU\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2"? Should I set it as the value of the default key?
-
VonC over 14 years@Pieter: If I believe cygwin.com/ml/cygwin/2001-04/msg00076.html, maybe by adding a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/etc
, with:(default) =
C:/CygWin/etc'` andflags = 0x0000000a
-
Pieter over 14 yearsI added the key to the registry, but Cygwin GCC is still not listed as a supported toolchain. By the way, I think I recall reading that Cygwin 1.7+ no longer stores the mounts in the registry so maybe that has something to do with it.
-
VonC over 14 years@Pieter: correct, cygwin.com/cygwin-ug-net/ov-new1.7.html#ov-new1.7-os : try to declare the /etc mount point in
/etc/fstab
instead. -
Pieter over 14 yearsLike this?
/cygdrive/c/cygwin/etc /etc cygdrive defaults 0 0
-
VonC about 14 years@Pieter: I missed your last comment. Did you make any progress on that issue?
-
Pieter about 14 yearsNo I didn't. I still haven't figured out how I can make Eclipse recognize Cygwin.
-
Pieter about 14 yearsIt has worked before in directories that contain spaces, but I'll try it anyway. I'll get back to you later today, hopefully.
-
Pieter about 14 yearsYou're right, for some reason the debugger doesn't like directory names with spaces in them. But that doesn't explain why Eclipse used to be able to debug programs like this inside the same directory structure that contained spaces in some folder names. I think I'm onto something: mingw.org/wiki/Getting_Started
-
Pieter about 14 yearsPutting the EXE in a path that doesn't contain spaces does work, but then I can't use Eclipse to debug. Any patches or workarounds I can try?
-
Alok Singhal about 14 yearsI found eclipse.org/forums/index.php?&t=msg&th=46794, so looks like your best bet is to use a folder without spaces for now.
-
Alok Singhal about 14 yearsWhy can't you use eclipse to debug? You should install eclipse and mingw in directories without spaces in their names. It's a silly restriction, but you might have to live with it. Good luck!
-
Pieter about 14 yearsI keep my Eclipse projects in a Dropbox subdirectory, the root of which is located in C:\Documents and Settings\Pieter De Decker\Mijn documenten\Dropbox\. So there's no way I can put it in a directory without spaces. Why is this such a big deal anyway? Isn't this a minor technical glitch that can be fixed easily?
-
Alok Singhal about 14 years@Pieter: I agree with you - unfortunately I haven't been able to find a way of overcoming that restriction yet. It really is a silly restriction.
-
Alok Singhal about 14 yearsHere's an email by someone who got eclipse and cygwin to work properly: old.nabble.com/…. You might want to try that maybe?
-
Pieter about 14 yearsAre you suggesting my problem is caused by a malformed PATH? Just in case, here it is:
%CommonProgramFiles%\Microsoft Shared\Windows Live;C:\Program Files\CVSNT\;C:\Program Files\doxygen\graphviz\bin;C:\Program Files\Java\jdk1.6.0_18\bin;C:\MinGW\bin
I put GDB in C:\MinGW\bin. -
Alok Singhal about 14 yearsNo, that link was to make eclipse work with cygwin. The problem with spaces is due to eclipse CDT and gdb interaction, and there seems to be no easy way out of it. See if you can do what you're doing with symbolic links, so you still put files in your dropbox, but have a symlink to it that is a name without spaces, and use that path in eclipse. en.wikipedia.org/wiki/NTFS_symbolic_link
-
Pieter about 14 yearsI'm an XP user, so no symbolic links for me... :-(
-
Alok Singhal about 14 yearsMaybe try shell-shocked.org/article.php?id=284#proggies, in particular the "junction" program may be able to help you with symlinks. I totally feel your frustration, though. Junction seems to be at technet.microsoft.com/en-us/sysinternals/bb896768.aspx, and here is a list of more programs: blog.taragana.com/index.php/archive/…
-
Pieter about 14 yearsIf I do
gdb "C:\Documents and Settings\Pieter\Bureaublad\CH14O01.exe"
(this file does in fact exist), the debugger returns the same error even though there's no forward slash this time:Error creating process C:\Documents and Settings\Pieter\Bureaublad\CH14O01.exe, (error 193).
. -
Jake Petroules almost 14 yearsI had the same problem in Qt Creator and this solution (removing spaces from the path) worked for me.