Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdl-vscode-c-cpp-debug/ #4

Open
utterances-bot opened this issue Jul 1, 2024 · 10 comments
Open

sdl-vscode-c-cpp-debug/ #4

utterances-bot opened this issue Jul 1, 2024 · 10 comments
Labels
discussion Discussion

Comments

@utterances-bot
Copy link

SDL on VSCode with C/C++

This practical guide shows a complete setup to configure VSCode for videogame programming with SDL2 and C/C++. Installation of additional libraries such as SDL Image, SDL Mixer and SDL TTF is also covered by this tutorial.

https://thescienceofcode.com/sdl-vscode-c-cpp-debug/

Copy link

Please extract the part where you mentioned sdl files in the path c:\sdl2. What to do with duplicate files? For example, there is a bin folder in the mixer, but when extracting, it is mixed with another bin folder.

@dacanizares
Copy link
Member

Hi @HassanChobaki24 !

Just merge those folders. In the end, for example, your c:\sdl2\bin should contain:

  • SDL2.dll
  • SDL2_image.dll
  • SDL2_mixer.dll
  • SDL2_ttf.dll
  • sdl2-config

Happy coding!

Copy link

I followed the steps yet get the "SDL2/SDL.h: No such file or directory" error even though this file does exist. I wish I could provide more information, but I really don't what might be causing this. Maybe I did the environment variable incorrectly, but I double checked. My SDL file path is as follows "C:\sdl2\include\SDL2\SDL.h"

@dacanizares
Copy link
Member

dacanizares commented Jul 10, 2024

Seems that your editor is not using the correct build for Windows. Please try these steps:

  1. Run manually the file build-win.bat.
  2. That should work, if so double check that your editor is running the build process for Windows.
    image

Best regards.

@Axelsmoon
Copy link

Yeah, I ran the windows build and it gives me the no such file or directory error,
"main.cpp:17:23: fatal error: SDL2/SDL.h: No such file or directory
#include <SDL2/SDL.h>
^"
when I run the debug windows I get this error.
"build/win/main.exe doesn't exist" "open launch.json"
I've been meaning to start programming a game, but the first step of installing sdl has been really holding me back haha.
I believe there is something about vs code and C++ includes that I do not understand, and that's why I'm not able to fix the issue. I'm still somewhat of a beginner for C++

@HassanChobaki24
Copy link

HassanChobaki24 commented Jul 11, 2024 via email

@dacanizares
Copy link
Member

dacanizares commented Jul 12, 2024

Yeah, I ran the windows build and it gives me the no such file or directory error, "main.cpp:17:23: fatal error: SDL2/SDL.h: No such file or directory #include <SDL2/SDL.h> ^" when I run the debug windows I get this error. "build/win/main.exe doesn't exist" "open launch.json" I've been meaning to start programming a game, but the first step of installing sdl has been really holding me back haha. I believe there is something about vs code and C++ includes that I do not understand, and that's why I'm not able to fix the issue. I'm still somewhat of a beginner for C++

Hi @Axelsmoon,

Please try this:

Open your main.cpp and replace lines 13 to 19 from this:

#ifdef _WIN64
 #include <SDL.h>
 #include <SDL_image.h>
#else
 #include <SDL2/SDL.h>
 #include <SDL2/SDL_image.h>
#endif

To this:

#include <SDL.h>
#include <SDL_image.h>

Now it should compile for Windows. Probably a flag is missing somewhere on your system (or you're using WIN32 instead of WIN64), I'm not sure since I cannot access your machine, but that should do the trick.

Note: That disables Linux/Mac compilation.

@dacanizares
Copy link
Member

dacanizares commented Jul 15, 2024

Hi everyone!

We have updated the tutorial and we've added a link with all SDL files for Windows, ready to be extracted on your computer's root folder C:\.

Just in case, here is the link.

Happy coding!

@dacanizares dacanizares added the discussion Discussion label Aug 12, 2024
Copy link

Thanks for the tutorial! I have added the /Y flag to the xcopy option under windows to avoid typing 'A' all the time. The only thing that doesn't work is autocompletion so I will have to look into that!

@dacanizares
Copy link
Member

Hi @breinbaas !

This setup has auto-completion out-of-the-box. Please double check that you had all required extensions enabled.

If you find any fixes, please feel free to send a PR to our repo https://github.com/TheScienceOfCodeEDU/sdl-vscode-c-cpp

Best regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion
Projects
None yet
Development

No branches or pull requests

5 participants