1 year ago

#373595

test-img

Shrug

SDL2 Funtions Cannot Be Found While Compiling

I get this error:

C:\Users\User\AppData\Local\Temp\cce4CTZf.o:window.cpp:(.text+0xe): undefined reference to `SDL_Init'
C:\Users\User\AppData\Local\Temp\cce4CTZf.o:window.cpp:(.text+0x42): undefined reference to `SDL_CreateWindow'
C:\Users\User\AppData\Local\Temp\cce4CTZf.o:window.cpp:(.text+0x50): undefined reference to `SDL_GetWindowSurface'
C:\Users\User\AppData\Local\Temp\cce4CTZf.o:window.cpp:(.text+0x5f): undefined reference to `SDL_Delay'
C:\Users\User\AppData\Local\Temp\cce4CTZf.o:window.cpp:(.text+0x6a): undefined reference to `SDL_DestroyWindow'
C:\Users\User\AppData\Local\Temp\cce4CTZf.o:window.cpp:(.text+0x6f): undefined reference to `SDL_Quit'
e:/work/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libmingw32.a(main.o):main.c:(.text+0xd2): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status

when trying to compile this code:

#include <SDL2/SDL.h>

int main(int argc, char ** arg )
{
    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_Window * win = SDL_CreateWindow("Game", 30, 30, 600, 500, SDL_WINDOW_SHOWN);
    SDL_Surface * screen = SDL_GetWindowSurface(win);
    SDL_Delay(2000);
    SDL_DestroyWindow(win);
    SDL_Quit();
}

I tried making a new "include" path where the headers are stored, but it didn't work. I also tried just including the headers in the project folder itself, also didn't work.

Edit: I managed to compile the app.

c++

compiler-errors

sdl-2

0 Answers

Your Answer

Accepted video resources