Sublime Forum

Sublime Text project C++

#1

I run this code

#include <SDL.h>
#include <iostream>

int main(int argc, char* argv[]) {
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        std::cerr << "SDL could not initialize! SDL_Error: " << SDL_GetError() << std::endl;
        return 1;
    }

    SDL_Window* window = SDL_CreateWindow("SDL Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
    if (window == nullptr) {
        std::cerr << "Window could not be created! SDL_Error: " << SDL_GetError() << std::endl;
        SDL_Quit();
        return 1;
    }

    SDL_Surface* screenSurface = SDL_GetWindowSurface(window);
    SDL_FillRect(screenSurface, nullptr, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));
    SDL_UpdateWindowSurface(window);

    SDL_Delay(2000);

    SDL_DestroyWindow(window);
    SDL_Quit();

    return 0;
}

but it says

C:\Program Files\Sublime Text 3\Simple DirectMedia Layer\src\main.cpp:1:10: fatal error: SDL.h: No such file or directory
    1 | #include <SDL.h>
      |          ^~~~~~~
compilation terminated.
[Finished in 516ms]

How do I repair that issue?

0 Likes

#2

Have you downloaded SDL?

Also it looks like you’re saving your files in C:\Program Files. That’s not where you should be saving anything and those files will be deleted when ST updates.

0 Likes