4

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

Chris
  • 3,619
  • 8
  • 44
  • 64
  • 1
    Maybe this will help you: http://stackoverflow.com/questions/9629349/soil-not-linking-correctly – mfc Feb 07 '13 at 12:57
  • @mfc: I've updated my question with the new error codes. Is that changing your reply? – Chris Feb 07 '13 at 13:28
  • LNKxxxx errors indicate that the error is from the linker, the code compiled fine, but the linker is not able to locate all the binary parts (both code and variables) from the external library. Could be the path of the LIB file too. The article in the link above saids that he use the "SOIL.lib" instead of "libSOIL.lib" and problem is solved. – mfc Feb 07 '13 at 15:48
  • I'm having the same problem but SOIL.lib/libsoil.lib doesn't do anything. – RaenirSalazar Mar 27 '14 at 23:44

3 Answers3

2

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.

eaglesky
  • 730
  • 2
  • 13
  • 28
0

Try including first your OpenGL before SOIL.h.

mr5
  • 548
  • 1
  • 5
  • 14
  • I've edited my question with some extra info. I am doing as you said but no luck when i am using code from soil. – Chris Feb 07 '13 at 12:28
0

Before these libraries use

include windows.h

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

Community
  • 1
  • 1
Crew HaXor
  • 675
  • 1
  • 8
  • 16
  • I would NOT recommend this. Just because someone is (believed to be) working on Windows (though that was never stated, and can only be inferred by the use of Visual Studio), it doesn't mean their project isn't going to be platform non-specific. Slapping the Windows header in there isn't a solution to a problem. In fact, it's more likely to create more problems (the myriad of countless compile warnings alone make it not worth it!) – Logix Jan 01 '22 at 17:37