0

I am trying to setup sdl2 to vs code but getting these errors:

Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes. If you want to re-enable it, run 'Import-Module PSReadLine'.

PS C:\Users\91790\Desktop\templateSDL> make
g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2
C:\Users\91790\AppData\Local\Temp\ccpT2dRR.o:main.cpp:(.text+0xf): undefined reference to `SDL_Init'
C:\Users\91790\AppData\Local\Temp\ccpT2dRR.o:main.cpp:(.text+0x43): undefined reference to `SDL_CreateWindow'
C:\Users\91790\AppData\Local\Temp\ccpT2dRR.o:main.cpp:(.text+0x51): undefined reference to `SDL_GetError'
C:\Users\91790\AppData\Local\Temp\ccpT2dRR.o:main.cpp:(.text+0x96): undefined reference to `SDL_PollEvent'
C:\Users\91790\AppData\Local\Temp\ccpT2dRR.o:main.cpp:(.text+0xb7): undefined reference to `SDL_DestroyWindow'
C:\Users\91790\AppData\Local\Temp\ccpT2dRR.o:main.cpp:(.text+0xbc): undefined reference to `SDL_Quit'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1
PS C:\Users\91790\Desktop\templateSDL> 
genpfault
  • 51,148
  • 11
  • 85
  • 139
  • 1
    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) – Biffen Mar 15 '23 at 12:34
  • @Biffen: OP is using `-lSDL2` to link to the SDL library, so I don't think that your proposed duplicate is correct. – Andreas Wenzel Mar 15 '23 at 12:47
  • 1
    Did you compile the SDL2 library yourself? If so, how exactly did you do that? Did you follow any specific instructions? – Andreas Wenzel Mar 15 '23 at 12:50
  • 1
    Maybe a 32/64 bit compatibility issue? Hard to say. – john Mar 15 '23 at 12:50
  • `c:/mingw/bin/../lib/gcc/mingw32/6.3.0` I can see you did not follow the VSCode recommendations to use msys2 to install MinGW: [https://code.visualstudio.com/docs/cpp/config-mingw](https://code.visualstudio.com/docs/cpp/config-mingw) if you did so your gcc version would be 12.2 and you can install SDL2 using pacman. – drescherjm Mar 15 '23 at 13:38
  • When you add `-l...` and such errors don't disappear, this normally means that the .a/.dll files you got don't match your compiler (x32 files with x64 compiler, or vice versa). I second drescherjm's advice: reinstall the compiler from MSYS2 (yours is quite outdated), and use it to install SDL2 as well. [Here's a guide](https://stackoverflow.com/q/30069830/2752075). – HolyBlackCat Mar 15 '23 at 18:53

0 Answers0