I just started learning about OpenGL, and I've been trying to load an image using SOIL. I need help with resolving these error that pop up when I try building the project:


Code:

C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glBindTexture@8'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexImage2D@36'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexImage2D@36'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glDeleteTextures@8'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glGenTextures@8'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glReadPixels@28'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glBindTexture@8'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glBindTexture@8'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexImage2D@36'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexImage2D@36'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexImage2D@36'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glGenTextures@8'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glBindTexture@8'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glBindTexture@8'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexParameteri@12'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSOIL.a(SOIL.o):SOIL.c|| undefined reference to `glTexImage2D@36'|
||=== Build finished: 35 errors, 0 warnings (0 minutes, 1 seconds) ===|


This is the code I am using:


Code:

#include <SOIL.h>
#include <GL/gl.h>
#include <GL/glfw.h>


int main()
{
    int     width, height;
    int     frame = 0;
    bool    running = true;

    glfwInit();

    if( !glfwOpenWindow( 1600, 900, 0, 0, 0, 0, 0, 0, GLFW_FULLSCREEN ) )
    {
        glfwTerminate();
        return 0;
    }

    glfwSetWindowTitle("TextureTest");

    GLuint tex_2d = SOIL_load_OGL_texture (
        "TestImage.tga",
        SOIL_LOAD_AUTO,
        SOIL_CREATE_NEW_ID,
        SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
    );

    {
        frame++;

        glfwGetWindowSize( &width, &height );
        height = height > 0 ? height : 1;

        glViewport( 0, 0, width, height );

        glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );
        glClear( GL_COLOR_BUFFER_BIT );

        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        glOrtho(0.0,width,height,0.0,-1.0,1.0);

        glfwSwapBuffers();
       

        // exit if ESC was pressed or window was closed
        running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam( GLFW_OPENED);
    }

    glfwTerminate();

    return 0;
}


I have the SOIL.h file in the Code::Blocks include folder, and the libSOIL.a file in the lib folder. The library file is linked to the compiler.
Looks like you aren't linking against the OpenGL libraries.
How would I go about doing that?
You need to add linker flags for GLFW at the least, and probably also GL. I don't know what those libraries or flags look like on your system, but I'm sure Google can tell you. Google "linking GL and GLFW from MinGW and codeblocks" or something along those lines.
I got it to work! I had the GLFW libraries linked, but it turns out that the GL library was not linked. I had assumed it was before because I had made some test programs using some of the functions, so its puzzling that those worked. Thank you for the help!
Good work! Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement