Search code examples
cvisual-studioopenglsoil

SOIL set-up in Visual Studio 2010


I cant get SOIL working correctly with Visual Studio 2010 – I’m far from an expert with VS but as far as I know only the following steps are necessary to get the environment working:

Properties>>C/C++>General>>Additional include directories Add in the path to SOIL.h

Properties>>Linker>>General>>Additional Library Directories Add in the path to libSOIL.a

I am also using free GLUT and the paths to the glut files are set here as well – I also set the Dubugging>>Environment Path to the GLUT bin file.

When I use the SOIL_load_OGL_texture I get the following error:

error LNK2019: unresolved external symbol _SOIL_load_OGL_texture referenced in function "void __cdecl init(void)" (?init@@YAXXZ)

Tried renaming libSOIL.a to libSOIL.lib and SOIL.lib but it didn’t work. I then built the VC8 project and used that .lib as suggested here SOIL not linking correctly but that didn’t work either.

I am using sample code from their homepage

GLuint tex_2d;
tex_2d = SOIL_load_OGL_texture
    (
        " C:\\Sunset.png",
        SOIL_LOAD_AUTO,
        SOIL_CREATE_NEW_ID,
        SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
    );

/* check for an error during the load process */
if( 0 == tex_2d )
{
    printf( "SOIL loading error: '%s'\n", SOIL_last_result() );
}

Solution

  • It sounds like you didn't actually put SOIL.lib in your Properties -> Linker -> Input -> Additional Dependencies list.

    The FreeGLUT header has some Win32-specific #pragmas to pull in the proper .lib files, which is why just setting the Additional Library Directories worked for that. SOIL doesn't have those so you have to specifically tell the linker which .lib to use.