简体   繁体   English

未定义引用`SOIL_load_OGL_texture'?

[英]undefined reference to `SOIL_load_OGL_texture'?

I am don't know why this keeps saying: 我不知道为什么这样说:

undefined reference to "SOIL_load_OGL_texture 未定义的引用“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>

It turns out you have to link libSOIL before linking libopengl32 . 事实证明,您必须在链接libopengl32之前链接libSOIL So, for example: 所以,例如:
g++ -g source.cpp -lglu32 -lSOIL -lopengl32 -lfreeglut will work, but leaving libSOIL last will result in the error above. g++ -g source.cpp -lglu32 -lSOIL -lopengl32 -lfreeglut可以工作,但最后保留libSOIL会导致上面的错误。

Look in "Simple OpenGL Image Library/projects/makefile", then create a directory there called "obj". 查看“Simple OpenGL Image Library / projects / makefile”,然后创建一个名为“obj”的目录。 Now run "make" from commandline where the makefile is and then "make install". 现在从命令行运行“make”,其中makefile是,然后是“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. 如果您收到有关libm的任何错误,只需在链接选项中添加“-lm”即可。

undefined reference mean that you need link soil library to your application. undefined reference表示您需要将土壤库链接到您的应用程序。 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. 在Linux上,您需要向链接器标志添加类似-lsoil的内容。

you have to link against the SOIL library: 你必须链接到SOIL库:

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

SOIL has to be in caps SOIL必须采用上限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM