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

I need to use SOIL lib in my project.

I included the SOIL.h and libSOIL.a directories in my source file (renamed it to libSOIL.lib).

I added the header file to the headers as an existing element and included the header file in another header file that I need.

I also tried: Project Properties> Linker> Input> Additional Dependencies, and then click "<Edit ..>" in the drop-down menu and type libSOIL.lib.

But I get the following errors:

See below (updated errors)

What should I do?

Edit # 1:

This is what I do:

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

I have both files in my source directory.

Without code written from SOIL, the assembly 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 get this error:

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

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

Error 3 LNK1120 errors: 2 unsolved externals working_dir \ Debug \ ProjectName.exe ProjectName

+4
source share
3 answers

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

+1
source

Try enabling OpenGL first before SOIL.h.

0
source

Before using these libraries,

enable windows.h

because you are working on windows. Your problem will be resolved.

0
source

All Articles