0

I'm trying to make a game on visual studio 2013 with SDL.
when I'm typed :

SDL_Surface* pTempSurface = IMG_Load("assets/na.png"); <br><br>

error occurred like :

Error 2 error LNK2019: unresolved external symbol _IMG_Load referenced in function

I already check project properties, c/c++,linker Additional Include/Library Directories and I also checked Linker|Input|Addtional Dependencies
, header files, place dll files to excutable folder too.

I don't know why this problem happened.
Can anyone tell me what should I do?

2

1 Answer 1

1

This is a linking problem, which means that when Visual Studio is trying to link you code to the already compiled SDL_image one, it is not finding the binary for this method.

The only way to solve this is by checking the following:

  • The path to the .lib files has to be correctly inserted at Project -> Properties-> VC++Directories -> Library Directories
  • The flag that links the library is correctly inserted at Project -> Properties -> Linker -> Input -> Additional Dependencies (SDL_image.lib)

If the problem were a missing DLL, it would crash on runtime. It it were a missing header, it would give a compiler error saying that the IMG_Load was not defined.

1
  • This solved my issue. So you need to set the include directories up, then the lib directories up, then as if that wasn't enough in Windows land, you also need to tell it which libs it will use by name... Okay thanks for the help.
    – Owl
    Commented Sep 11, 2018 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.