1

I want to debug a code with codeblocks. It is not possible if I use the SDL2 lib.

The building of the bin/debug/*.exe is ok...but when I run it there is the following message:

Starting debugger: gdb.exe -nx -fullname -quiet  -args .../bin/Debug/dsl2_test4.exe
done
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 8.1
Error creating process ...\bin\Debug\dsl2_test4.exe, (error 193).
Debugger finished with status 0

It appears when I add #include <SDL.h>

Has someone an idea to solve my problem because I would like to debug complex code using SDL2...

example of code:

#include <exception>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <SDL.h>   

int main(int argc, char* argv[])
{
 int a;
 int b = 5;
 a = b+6;
 return 0;
}

I want to run a debug *.exe with "#include <SDL.h>"


edit 1


build log is :

-------------- Clean: Debug in dsl2_test4 (compiler: GNU GCC Compiler)---------------

Cleaned "dsl2_test4 - Debug"

-------------- Build: Debug in dsl2_test4 (compiler: GNU GCC Compiler)---------------

g++.exe -Wall -g -I..\SDL2\SDL2-devel-2.24.0-mingw\SDL2-2.24.0\x86_64-w64-mingw32\include\SDL2 -c ...\dsl2_test4\main.cpp -o obj\Debug\main.o
g++.exe -LC:\SDL2\SDL2-devel-2.24.0-mingw\SDL2-2.24.0\x86_64-w64-mingw32\lib -o bin\Debug\dsl2_test4.exe obj\Debug\main.o   -lmingw32 -lSDL2main -lSDL2.dll -luser32 -lgdi32 -lwinmm -ldxguid
\dsl2_test4\main.cpp: In function 'int SDL_main(int, char**)':
\dsl2_test4\main.cpp:11:9: warning: variable 'a' set but not used [-Wunused-but-set-variable]
     int a;
         ^
Output file is bin\Debug\dsl2_test4.exe with size 85.52 KB
Running project post-build steps
XCOPY ...\SDL2\SDL2-devel-2.24.0-mingw\SDL2-2.24.0\x86_64-w64-mingw32\bin\*.dll bin\Debug\ /D /Y
0 fichier(s) copi‚(s)
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 1 warning(s) (0 minute(s), 1 second(s))

(I have manually copied SDL2.dll in bin/debug)


Compiler and Debugger settings are

Debugger settings -> GDB/CDB debugger -> Default : excutable path : C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe

Compiler settings ->Debugger : GDB/CDB debugger : Default


6
  • 3
    Make sure the SDL DLL files are in the same directory as the executable and they are the proper version, 64 or 32 bit, to match the application. Commented Jan 14, 2023 at 9:46
  • Error 193 is ERROR_BAD_EXE_FORMAT which means either your program or the one of the DLL's it uses is not a valid executable/DLL file. Commented Jan 14, 2023 at 9:47
  • Can you please edit your question to tell (and show?) exactly how you build your program (for example copy-paste the full and complete verbose build-log into the question)? What is your configuration for building (flags, libraries, etc.)? Commented Jan 14, 2023 at 9:48
  • I use "codeblocks-20.03mingw-setup" that includes GDB debugger from MinGW-W64 project (version 8.1.0, 32/64 bit,SEH) and SDL2-devel-2.24.0-mingw Commented Jan 14, 2023 at 17:07
  • SDL2.dll is in the same directoty as the executable. And the .exe runs in debug mode without "#include <SDL.h>" Commented Jan 14, 2023 at 17:10

1 Answer 1

0

looking at other forums, the problem is solved : I add "#undef main" after "#include <SDL.h>"

Sign up to request clarification or add additional context in comments.

1 Comment

Not solved, postponed. Once you try to use SDL functionality you'll have two problems, the original and the one that #undef main causes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.