How to link static library (of SOIL) to a project in visual studio 2010?

Chris picture Chris · Feb 7, 2013 · Viewed 8.3k times · Source

I need to use SOIL lib at my project.

I've included at my source files director the SOIL.h and libSOIL.a (renamed it to libSOIL.lib).

I've added the header file to the headers as an existing item and include the header file in another header file that I need it.

I've also tried: Project properties > Linker > Input > Additional Dependencies and then at the dropdown menu clicked on "< Edit.. >" and typed libSOIL.lib.

But I am getting these errors:

Look below (updated errors)

What should I do?

Edit #1:

This is what I am doing:

#include "gl/glut.h"  
#include "SOIL.h"

I have both files at my source directory.

Without any code written from SOIL the build succeeds.

With this code:

/* load an image file directly as a new OpenGL texture */
GLuint grass_texture = SOIL_load_OGL_texture
(
    "original.bmp",
    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 == grass_texture )
{
    printf( "SOIL loading error: '%s'\n", SOIL_last_result() );
}

I am getting this error:

Error 1 error LNK2019: unresolved external symbol __alloca referenced in function _stbi_zlib_decode_noheader_buffer working_dir\libSOIL.lib(stb_image_aug.o) ProjectName

Error 2 error LNK2019: unresolved external symbol _sqrtf referenced in function _RGBE_to_RGBdivA2 working_dir\libSOIL.lib(image_helper.o) ProjectName

Error 3 error LNK1120: 2 unresolved externals working_dir\Debug\ProjectName.exe ProjectName

Answer

eaglesky picture eaglesky · Feb 17, 2015

I met the same problem. My solution was to go to the projects/VCX folder and compile the solution myself, then copied the generated .lib file to my project. When you compile the solution, make sure you choose the right platform(X86/X64). Also make sure the path containing the .lib file can be found by your project.