0

I have set up a development environment in VSCode with SDL2, SDL2_Image and MinGW. I am using this command to compile the program.

g++ -Isrc/include -Lsrc/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2 -lSDL2_image

I have SDL2_image.h in src/include/SDL2. I have libSDL2_image.(a/dll.a/la) all in src/lib. I have the SDL2_image.dll in the project folder.

I am including SDL_image like so

#include "SDL2/SDL_image.h"

The program will compile fine as along as I am not using the IMG_Load function, if I do it throws the error: undefined reference to `IMG_Load'.

To my knowledge, I have dragged all necessary files and included them in the appropriate folders. VSCode seems to recognize the file SDL_image.h, so I am unsure why the reference to IMG_Load remains undefined.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • When you say: `it throws the error: undefined reference to 'IMG_Load'` do you mean compilation error? Possible duplicate of [‘IMG_Load’ was not declared in this scope SDL 2](https://stackoverflow.com/a/35211720/2085626) or [How to use SDL2 and SDL_image with cmake](https://stackoverflow.com/questions/23850472/how-to-use-sdl2-and-sdl-image-with-cmake). – Amir Kirsh Dec 13 '22 at 00:54
  • I needed to use the 32 bit library for some reason. All of the tutorials I have seen use the 64 bit library, something about my setup is different. – ScruffyNerf Dec 13 '22 at 01:10
  • This just means your compiler is 32-bit. – HolyBlackCat Dec 13 '22 at 07:39

0 Answers0