Home > Blockchain >  SOIL unresolved external symbols
SOIL unresolved external symbols

Time:12-09

Ok, before anyone marks this question as a duplicate, I have looked at What is an undefined reference/unresolved external symbol error and how do I fix it? and many other online posts. I've tried every solution I've come acoss but I still can't fix these errors:

1>SOIL.lib(stb_image_aug.o) : error LNK2019: unresolved external symbol __alloca referenced in function _stbi_zlib_decode_noheader_buffer
1>SOIL.lib(image_helper.o) : error LNK2019: unresolved external symbol _sqrtf referenced in function _RGBE_to_RGBdivA2

I'm using Visual Studio 2012 on Windows 8. I've tried rebuilding the library and I have quintuple checked all my includes and directories.Here are the SOIL includes/directory I have:

>Configuration Properties->VC   Directories->Include Directories: "C:\SOIL\Simple OpenGL Image Library\src
>Configuration Properties->VC   Directories->Library Directories: "C:\SOIL\Simple OpenGL Image Library\lib
>Congiguration Properties->Linker->Input->Additional Dependencies: "SOIL.lib"

And here's my code. The SOIL_load_image function is what's causing the errors:

#include <Windows.h>
#include <GL/glut.h>
#include "glext.h"
#include <SOIL.h>

void glEnable2D( void );
void display();
void glDisable2D( void );

GLuint tex;

/* Main function: GLUT runs as a console application starting at main()  */
int main(int argc, char** argv) 
{
    glutInit(&argc, argv);                 // Initialize GLUT
    glutCreateWindow("OpenGL Setup Test"); // Create a window with the given title
    glutInitWindowSize(320, 320);   // Set the window's initial width & height
    glutInitWindowPosition(50, 50); // Position the window's initial top-left corner

    //Texture
    glGenTextures(1, &tex);
    glBindTexture(GL_TEXTURE_2D, tex);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
    float color[] = { 1.0f, 0.0f, 0.0f, 1.0f };
    glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    int width, height;
    unsigned char* image = SOIL_load_image("Resources/Sprites/playerCharacter.png", &width, &height, 0, SOIL_LOAD_RGB);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
    SOIL_free_image_data(image);
    //Texture

    glutDisplayFunc(display); // Register display callback handler for window re-paint
    glutMainLoop();           // Enter the infinitely event-processing loop
    return 0;
}

I've been working on this all day and I haven't been able to figure out what I'm doing wrong, and it's been extremely frustrating. Note: I know the original name of SOIL.lib is "libSOIL.a." I tried working with it with that name and got the same errors.

CodePudding user response:

You can build the VC8 or VC9 solution files yourself in VS2012/13. Just make sure you are Win32 configuration if you are building a 32bit application. Change the configuration properties to x64 if you are building a 64bit application. Once the projects are built, link your openGL project to your these generated SOIL.lib files and you will be good to go.

  • Related