0

I am trying to load an image as a texture with OpenGL using C++ in Visual Studio 2010. I researched for a couple hours online and found the SDL library, then I implemented a simple example and got some linking error I can not seem to figure out. The error log is here:

1>Build started 10/20/2012 12:09:17 AM.
1>InitializeBuildStatus:
1>  Touching "Debug\texture mapping test.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>  texture mapping test.cpp
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>texture mapping test.obj : error LNK2019: unresolved external symbol _IMG_Load referenced in function "void __cdecl display(void)" (?display@@YAXXZ)
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\Me\Documents\Visual Studio 2010\Projects\Programming projects\texture mapping test\Debug\texture mapping test.exe : fatal error LNK1120: 2 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.45
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I downloaded the SDL, and copied all the .h file into:

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include

I added the .lib (x86) files into:

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib

(Note: I tried the (x64) file too but got the exact same error)

And the .dll(x86) into:

C:\Windows\System32

For implementing textures, I used the simple sample code from: SDL Tip - SDL Surface to OpenGL Texture

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • 6
    You should really not pollute the include and library directories of your Visual Studio with third party libraries, nor put third party software in the system directories. Not that this is the cause of your lack of understanding of the compilation model, it's just essential hygiene. – Lars Viklund Oct 20 '12 at 04:45
  • What Lars says is absolutely correct. The proper way to go about it is to right-click on your project and select properites, and put the library directories under Additional Library Directories in the Linker category. Additionally, you'll have to add specific .lib files to the Additional Dependencies under the Linker->Input category. – kevintodisco Oct 21 '12 at 06:07

3 Answers3

3

Ensure that you link both with sdl.lib and sdlmain.lib.

Also, it seems that you're using SDL_Image. You should also try to link with sdl_image.lib to fix the first of your two errors.

Benlitz
  • 1,952
  • 1
  • 17
  • 30
0

Did you check the right active solution platform under configuration manager?

Mat90
  • 169
  • 1
  • 9
0

Make a folder in your project directory and try using the linker settings to connect to those files. That is what I did when this error occurred. Also make sure you are compiling with the same sdl lib type (x86 or x64).