3

I am don't know why this keeps saying:

undefined reference to "SOIL_load_OGL_texture

This is the code:

GLuint loadtex( const char* texname )
{
    GLuint texture = SOIL_load_OGL_texture(
                                              texname,
                                              SOIL_LOAD_AUTO,
                                              SOIL_CREATE_NEW_ID,
                                              SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
                                              );
    glBindTexture( GL_TEXTURE_2D, texture );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    return texture;
}

I have

#include <SOIL.h>
Thomas Fenzl
  • 4,342
  • 1
  • 17
  • 25

4 Answers4

8

It turns out you have to link libSOIL before linking libopengl32. So, for example:
g++ -g source.cpp -lglu32 -lSOIL -lopengl32 -lfreeglut will work, but leaving libSOIL last will result in the error above.

Random Dude
  • 81
  • 1
  • 3
5

Look in "Simple OpenGL Image Library/projects/makefile", then create a directory there called "obj". Now run "make" from commandline where the makefile is and then "make install". That should install the library and header file. Try compiling now; it worked for me. If you receive any errors about libm, just add "-lm" to your linking options.

Austin Stephens
  • 401
  • 4
  • 9
1

undefined reference mean that you need link soil library to your application. There are different ways to do it, it depends on platform and compiler that you used. On Linux you need add something like -lsoil to linker flags.

fghj
  • 8,898
  • 4
  • 28
  • 56
0

you have to link against the SOIL library:

g++ -o output your-source.cpp -lSOIL

SOIL has to be in caps

hetepeperfan
  • 4,292
  • 1
  • 29
  • 47