# Need help to setup SDL2 in visual studio code.

**URL:** <https://discourse.libsdl.org/t/need-help-to-setup-sdl2-in-visual-studio-code/38693>\
**Category:** SDL Development\
**Created:** [September 7, 2022, 1:23pm UTC](https://discourse.libsdl.org/t/need-help-to-setup-sdl2-in-visual-studio-code/38693 "2022-09-07T13:23:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scorp](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/51bf81/32.png) [@Scorp](https://discourse.libsdl.org/u/Scorp)\
**Post date:** [September 7, 2022, 1:23pm UTC](https://discourse.libsdl.org/t/need-help-to-setup-sdl2-in-visual-studio-code/38693/1 "2022-09-07T13:23:58Z")

</div>

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

 ![Capture](https://discourse.libsdl.org/uploads/default/original/2X/b/b32fedc3dd1239de4759c9e1cf3e55f0c6450d23.png)

---

<div class="post-metadata">

**Author:** ![Petruska](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/petruska/32/4449_2.png) [@Petruska](https://discourse.libsdl.org/u/Petruska)\
**Post date:** [September 7, 2022, 5:16pm UTC](https://discourse.libsdl.org/t/need-help-to-setup-sdl2-in-visual-studio-code/38693/2 "2022-09-07T17:16:57Z")

</div>

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:  
 ![image](https://discourse.libsdl.org/uploads/default/original/2X/6/62c96d6732c584bcf4c0647ba18377a49214e9c7.png)

Let me know if it works out!

---

<div class="post-metadata">

**Author:** ![Scorp](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/51bf81/32.png) [@Scorp](https://discourse.libsdl.org/u/Scorp)\
**Post date:** [September 8, 2022, 6:31am UTC](https://discourse.libsdl.org/t/need-help-to-setup-sdl2-in-visual-studio-code/38693/3 "2022-09-08T06:31:44Z")

</div>

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
- 

```auto

```

At line:1 char:1

- ./main
- 

```auto
  + CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
  + FullyQualifiedErrorId : NativeCommandFailed

```

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

---

<div class="post-metadata">

**Author:** ![Petruska](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/petruska/32/4449_2.png) [@Petruska](https://discourse.libsdl.org/u/Petruska)\
**Post date:** [September 8, 2022, 7:58pm UTC](https://discourse.libsdl.org/t/need-help-to-setup-sdl2-in-visual-studio-code/38693/4 "2022-09-08T19:58:24Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Scorp](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/51bf81/32.png) [@Scorp](https://discourse.libsdl.org/u/Scorp)\
**Post date:** [September 10, 2022, 8:25am UTC](https://discourse.libsdl.org/t/need-help-to-setup-sdl2-in-visual-studio-code/38693/5 "2022-09-10T08:25:35Z")

</div>

It is still showing the same error.

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

to this  
all:  
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.
