0

im trying to use SDL2 for first time and i compile and there r some error cause of the library

In function `main':
main.cpp:(.text+0x25): undefined reference to `SDL_Init'
main.cpp:(.text+0x31): undefined reference to `SDL_GetError'
main.cpp:(.text+0x80): undefined reference to `SDL_CreateWindow'
main.cpp:(.text+0x90): undefined reference to `SDL_GetError'
main.cpp:(.text+0xc1): undefined reference to `SDL_GetWindowSurface'
main.cpp:(.text+0xe4): undefined reference to `SDL_MapRGB'
main.cpp:(.text+0xf7): undefined reference to `SDL_FillRect'
main.cpp:(.text+0x103): undefined reference to `SDL_UpdateWindowSurface'
main.cpp:(.text+0x10d): undefined reference to `SDL_Delay'
main.cpp:(.text+0x119): undefined reference to `SDL_DestroyWindow'
main.cpp:(.text+0x11e): undefined reference to `SDL_Quit'
collect2: error: ld returned 1 exit status

To use the library i write

#include <SDL2/SDL.h>
  • 1
    what operating system are you on and where have you installed SDL2? – kennyvh Apr 15 '20 at 21:15
  • 3
    Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – a1ezh Apr 15 '20 at 21:15
  • 1
    You forgot to link against SDL. Add `-lSDL2` to your compiler flags. and make sure it's specified after the source/object files. – HolyBlackCat Apr 15 '20 at 21:36

0 Answers0