Problems using SDL2 on VS

Emilio Chang 41 Reputation points
2022-03-05T23:50:28.5+00:00

180320-image.png

180367-image.png

I'm following an SDL2 tutorial (form codergopher) but I'm having troubles with some keywords. As shown in the pictures, I'm coding on Visual Studio (codergopher is doing it on SublimeText) and I don't know if that's has something to do with the errors.
Also, he sets up SDL2 a bit different than I do on Visual Studio. What I do is go to project properties and include the 'include' and 'lib' directories (for both SDL2 and SDL2_Image), then go to linker and add as aditional dependencies 'SDL2.lib' and 'SDL2main.lib'.

Finally, there's something I don't understand. Why some people include the SDL2 library as '#include <SDL2/SDL.h>' and, when I try to do that, it gives me an error (I have to do it '#include <SDL.h>'

One more thing: I tried to set up SDL2 for a project on NetBeans but it didn't work. If someone could help me on that, I would appreciate it, since I don't like VS very much

Developer technologies C++
{count} votes

Accepted answer
  1. Minxin Yu 13,501 Reputation points Microsoft External Staff
    2022-03-07T02:12:38.377+00:00

    Hi, @Emilio Chang

    1. This is the description in the SDL_CreateWindow documentation:

    x: the x position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED

    1. '#include <SDL2/SDL.h>' It is due to different include directories.
      e.g.
      Directory: new folder/SDL2/SDL.h : project properties include -> new folder ,then #include <SDL2/SDL.h> . Or project properties include -> SDL2 ,then #include <SDL.h>
    2. Currently, NetBeans issues are not supported, you can go to other forums such as github for support.

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.