SOIL set-up in Visual Studio 2010
Asked Answered
O

2

7

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() );
}
Offbeat answered 22/10, 2012 at 10:3 Comment(0)
A
5

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.

Ancheta answered 22/10, 2012 at 14:7 Comment(2)
Thanks - works perfect. I know it asking another question but would you know of any good place to learn about linkers and that whole area (it hard to find a good place on the net that starts from the very basics)Offbeat
Not in particular. As in most things I'd start at Wikipedia: Linker (computing) and go where your curiosity takes you :)Ancheta
H
9

May be it's little old thread, still I will share something.

  1. Download the zip from http://www.lonesock.net/soil.html and unzip it.

  2. In your visual studio project include path (project -> properties -> vc++ directories -> include directories) add the path to "src" folder of Soil. Same place of -> library directories add the "lib" folder. project -> properties -> Linker -> Input -> Additional Dependencies -> Edit to add "SOIL.lib"

  3. This step is important as people tend to rename that .a file to .lib. Don't do that. Instead go inside "projects" folder, select a VC* (eg VC8 for VS2012) -> open the visual studio file -> it will open using your visual studio -> click ok -> click ok. Your solution will be Ready.

Now press F5/Run to build and Run. Be careful while doing it, in case your project is using a x64 Debug version then in here select the same before you build the solution.

  1. There will be folders/files created in the VC* folder. Go inside Debug/x64 (dependent on your project), copy the SOIL.lib file to original "lib" folder (you pointed to in Visual Studio Properties in step 2).

At this point, you are done. It should work.

Haydeehayden answered 19/4, 2015 at 23:7 Comment(1)
If you are just using it to draw the texture from an image, you can also use OpenCV to read the image and draw it. In this case you need to know the exact image data type.Haydeehayden
A
5

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.

Ancheta answered 22/10, 2012 at 14:7 Comment(2)
Thanks - works perfect. I know it asking another question but would you know of any good place to learn about linkers and that whole area (it hard to find a good place on the net that starts from the very basics)Offbeat
Not in particular. As in most things I'd start at Wikipedia: Linker (computing) and go where your curiosity takes you :)Ancheta

© 2022 - 2024 — McMap. All rights reserved.