Need help to setup SDL2 in visual studio code.

I just started SDL2 in visual studio code, I am new to this so don’t know much. But this is the error showing when I use mingw32-make command

Hi! Judging by the error you most likely mismatched the architectures of the libraries.

You can see in your terminal that mingw32-make defaults to x86_64-w64-mingw32. So make sure that you took the libraries with the same architecture from the devel archive:

Let me know if it works out!

1 Like

Yes that worked, Thank you

But now there is a new problem

Program ‘main.exe’ failed to run: The specified executable is not a valid application for this OS platform.At line:1 char:1

  • ./main

At line:1 char:1

  • ./main
  •   + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
      + FullyQualifiedErrorId : NativeCommandFailed

This is the error code that’s showing after fixing the libraries

Since you are on Windows, executable should end in .exe. So you should update your compile command to have -o main.exe.

Since you’re running from a terminal, the next issue you’re likely to encounter is a silent one. You may have noticed that the mingw libraries have a bin folder with SDL2.dll in it. You will need that DLL next to the .exe to run it. (It only shows up as a popup when you double click the executable from the file explorer)

It is still showing the same error.

I made the content in the Makefile
from this
g++ -I src/include -L src/lib -o main.exe main -lmingw32 -lSDL2main -lSDL2

to this
g++ -I src/include -L src/lib -o main.exe main.cpp -lmingw32 -lSDL2main -lSDL2

And copied the SDL2.dll into the VSCODE_GAME_1 folder.