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?

kyu
  • 11
  • 2
  • Please specify what you have configured in the Addition Include/Library Directory fields and also what you have put in Additional Dependencies for the Linker. Did you also include the SDL header file in code etc? – TPS Apr 19 '15 at 11:52
  • possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – genpfault Apr 23 '15 at 20:57

1 Answers1

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.

gibertoni
  • 1,368
  • 12
  • 21
  • 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 Sep 11 '18 at 15:58