SOIL set-up in Visual Studio 2010

2020-07-10 05:42发布

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() );
}

2条回答
Melony?
2楼-- · 2020-07-10 05:59

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.

查看更多
劳资没心,怎么记你
3楼-- · 2020-07-10 06:07

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.

查看更多
登录 后发表回答