I’m following a tutorial to install the SDL library on Visual Code Studio, but the code does not compile when i imput “make”, says it can’t find file [closed]

I’m following a tutorial to make a window for SDL 2 on Visual Code Studio (https://youtu.be/jUZZC9UXyFs?si=si2Cb39E9sCOlwX9).
As of now, the code is the following:
On the Makefile

all:
    g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2

and on the cpp

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

const int WIDTH = 800, HEIGHT = 600

int main( int argc, char *argv[] )

{ 
    SDL_Init( SDL_INIT_EVERYTHING );

    SDL_Window *window = SDL_CreateWindow( "Hello SDL WORLD", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT );

    if ( NULL == window )
    {
        std::cout << "Could not create window: " << SDL_GetError( ) << std::endl;
        return 1;
    }

    SDL_Event windowEvent;

    while ( true )
    {
        if ( SDL_PollEvent( &windowEvent ) )
        {
            if ( SDL_QUIT == windowEvent.type )
            { break; }
        }
    }

    SDL_DestroyWindow( window );
    SDL_Quit( );

    return EXIT_SUCCESS;
}

I wrote down all the code and then tried to compile the code using “make” in the terminal, but it didn’t recognize it as a command, so i installed stuff using Chocolately and now it does recognize the command but prints the following when i imput it:

PS C:\Users[user name]\Documents\SDLTemplate> make
g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2
process_begin: CreateProcess(NULL, g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2,
…) failed.
make (e=2): Impossibile trovare il file specificato.
make: *** [Makefile:2: all] Error 2

The part in italian on the sixth line means “could not find the specified file”.

I’m also getting four problems on the cpp. I’m pasting them in case they are relevant:

[{
    "resource": "/c:/Users/[user]/Documents/SDLTemplate/main.cpp",
    "owner": "C/C++: IntelliSense",
    "code": "65",
    "severity": 8,
    "message": "expected a ';'",
    "source": "C/C++",
    "startLineNumber": 6,
    "startColumn": 1,
    "endLineNumber": 6,
    "endColumn": 4
}]

[{
    "resource": "/c:/Users/[user]/Documents/SDLTemplate/main.cpp",
    "owner": "C/C++: IntelliSense",
    "code": "169",
    "severity": 8,
    "message": "expected a declaration",
    "source": "C/C++",
    "startLineNumber": 33,
    "startColumn": 5,
    "endLineNumber": 33,
    "endColumn": 11
}]

[{
    "resource": "/c:/Users/[user]/Documents/SDLTemplate/main.cpp",
    "owner": "C/C++: IntelliSense",
    "code": "260",
    "severity": 8,
    "message": "explicit type is missing ('int' assumed)",
    "source": "C/C++",
    "startLineNumber": 31,
    "startColumn": 5,
    "endLineNumber": 31,
    "endColumn": 13
}]

[{
    "resource": "/c:/Users/[user]/Documents/SDLTemplate/main.cpp",
    "owner": "C/C++: IntelliSense",
    "code": "65",
    "severity": 8,
    "message": "expected a ';'",
    "source": "C/C++",
    "startLineNumber": 6,
    "startColumn": 1,
    "endLineNumber": 6,
    "endColumn": 4
}]

I am not by any means a programmer, and i need help. I’m only doing this to be able to use the C version of SAM.

  • Did you install g++ and add the directory where it is located to your path? const int WIDTH = 800, HEIGHT = 600 is missing a ; at the end of the line.

    – 




  • 1

    Why do you tag the C++ code with C?

    – 




  • 3

    It looks like you’ve discovered a scarcely known fact: any clown can upload a video to Youtube. Even I can do it. Shocking, isn’t it? But it takes real money to publish a textbook. Dead trees aren’t cheap. A publisher won’t risk their investment in a textbook without thoroughly vetting and checking the material for quality and value. That’s why, anyone who’s serious about learning C++ will get a good textbook instead of watching videos or doing coding puzzles.

    – 

Leave a Comment