Uploading an image using DevIL: Linker errors

Hello Everyone,

I’m having linker errors and I hope you can help me. I’ve searched the web and tried all the solutions suggested but none is working for me. Below is just a few of the linker errors I am getting. Can someone help me out with it?

[Linker error] undefined reference to _imp__ilBindImage@4' [Linker error] undefined reference to_imp__ilLoadImage@4’
[Linker error] undefined reference to_imp__iluGetImageInfo@4' [Linker error] undefined reference to_imp__iluFlipImage@0’
[Linker error] undefined reference to _imp__iluGetInteger@4' [Linker error] undefined reference to_imp__ilutGetInteger@4’
[Linker error] undefined reference to _imp__iluInit@0' [Linker error] undefined reference toglfwSwapBuffers’
[Linker error] undefined reference to `glfwTerminate’

What system are you compiling at?

If it is Linux, you seem to be missing at least -lglfw. I don’t remember the devil library name, but isn’t it simply -il?

Anyway, you should find full build information at https://docs.google.com/viewer?url=http%3A%2F%2Fopenil.sourceforge.net%2Fdocs%2FDevIL%20Manual.pdf

Consider if you really need devIL. It may be much simpler to load something like bmp files. They are fairly easy to decode. I tried to do get an application to work in both Linux and Windows, but had problems to get all libraries working.

Using DevIL on both Linux and windows has worked well for me – no problems.

Note on Linux you need to add “-lIL -lILU” (case sensitive) to the link options. In some cases you may also be using “-lILUT”. Note this implies that it is correctly installed. For instance, on my Linux box


$ locate libIL
/usr/lib/libIL.a
/usr/lib/libIL.la
/usr/lib/libIL.so
/usr/lib/libIL.so.1
/usr/lib/libIL.so.1.1.0
/usr/lib/libILU.a
/usr/lib/libILU.la
/usr/lib/libILU.so
/usr/lib/libILU.so.1
/usr/lib/libILU.so.1.1.0
/usr/lib/libILUT.a
/usr/lib/libILUT.la
/usr/lib/libILUT.so
/usr/lib/libILUT.so.1
/usr/lib/libILUT.so.1.1.0

A guess command line usage for your case (if on linux)


g++ foo.cpp -o foo $(pkg-config libglfw --libs) $(pkg-config ILU --libs)

On my linux box, explicit pkg-config determined values are as follows


$ pkg-config libglfw --libs
-pthread -lglfw -lGL -lX11 -lXrandr -ldl -lm

$ pkg-config ILU --libs
-lILU -lIL

$ pkg-config ILUT --libs
-ILU -lILUT -lIL

From my memory DevIL is just a wrapper library. Check http://nothings.org/stb_image.c if you want to rid yourself of linker errors.

DevIL is not a wrapper around STB Image. DevIL can load what STB Image loads, but there’s a difference between doing the same thing and one being a wrapper around the other.

It is a wrapper around libpng, libjpeg, … and you need to compile&link those.

It’s also a “wrapper” around formats that STB Image cannot load. So he might be ridding himself of linker errors, but he’d also be ridding himself of functionality.

Better to learn how compiling and linking actually works.

Since she does not know how to compile&link, a simple library like stb_image might do the trick.

And certainly “uploading” an “image” using DevIL means she’s pretty new to GL.

Since she does not know how to compile&link

Then she should learn. Linking with libraries is a big part of what C and C++ programmers do. All avoiding it does is delay the inevitable. She’s going to have to learn sooner or later; better to do it now.

I am using a lot of bitmaps in my application. To save space, I used various formats. But when I had to use Devil, it turned out that several other libraries also had to be added. So maybe I am not that skilfull, but it was a mess to get it all working on Windows.

So I simplified, and use only bmp files now. It will use a little more disk space, but the installer application will compress them effectively anyway. It just wasn’t worth the effort.

If you are doing a small project, to learn OpenGL, then I would recommend the simple way. In the question from OP, there isn’t really enough information to give the best recommendations (as is quite common).

Yes I’m new to openGL and have been learning a lot of things on my own. I’m willing to learn if I am pointed in the right direction.

I’m using Windows

I don’t understand. How else can you link libraries if you are not using image libraries? I am using DevIL and I’m trying to link its libraries correctly. I’m using Dev C++. Under Project-> Project Options-> Parameters, I make sure I have the right paths to il ilu and ilut library files in there. The under Library Directories, I make sure I have the right path, for example: C:\Dev-Cpp\lib in there. I do the same for the Include Directories: C:\Dev-Cpp\include.

This is what I have in the Parameter box (where the library files must go):

-lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32

…/…/…/…/…/…/…/Dev-Cpp/lib/glew32.lib

…/…/…/…/…/…/…/Dev-Cpp/lib/DevIL.lib
…/…/…/…/…/…/…/Dev-Cpp/lib/ILUT.lib
…/…/…/…/…/…/…/Dev-Cpp/lib/ILU.lib

il does not have a library file. When you upload the path, the compiler automatically adds …/…/…/…/…/…/…/ to the beginning of the path.

I’ve played around with this for days and I don’t know what else is missing that I need to add. Please assist me. Thanks

Ah, you are using dev-c++ in windows … the DevIL devpak is a little unconventional in its use of library names. This affects the linker options …

goto “project options”
goto “parameters”
in column “Linker”
try -ldevil instead of the previously suggested “-lIL -lILU -lILUT”

This comes from the readme that comes with installing the devil dev-pak see windows start menu->programs->Bloodshed Dev-c+±>DevIL->README.

For what its worth my exact link column has


-lglfw 
-lglu32 
-lopengl32 
-lwinmm 
-lgdi32
-ldevil
-lglew32

The key point is to notice -ldevil.

Remove the following and use the above notation instead


../../../../../../../Dev-Cpp/lib/glew32.lib

../../../../../../../Dev-Cpp/lib/DevIL.lib
../../../../../../../Dev-Cpp/lib/ILUT.lib
../../../../../../../Dev-Cpp/lib/ILU.lib

Thanks so much for this information. I’ll try it immediately and let you know how it turns out. Thanks again.

By the way, I’m using dev-c++ in windows

By the way, I’m using dev-c++ in windows

Note: Dev-C++ is very old. You would be better served by switching to Code::Blocks, the modern equivalent.

All the errors disappeared except one. It says: cannot find -lglfw

I realized I didn’t have glfw.dll in my systems32. So I downloaded GLFW 2.7.2 again but the dynamic link library is not included.

Are you using the dev-paks?

To download and install from within the IDE:
goto tools
choose “check for Updates/Packages …”
select DevPak Server = devpaks.org Community Devpaks
click check for updates
select group “openGL”
click on “GLFW+OpenGL”
click “download selected”

Then you should be able to compile with -lglfw

Thanks. I’ll try that. I went to GLFW’s website and followed the instructions there. I compiled the GLFW program in the msvc100 folder which was in the GLFW folder I downloaded, and it built the .dll and .lib files. I used those but when I compiled the code, it gave me some weird errors: something about the files being outdated, plus the old errors I had.

So I’ll delete those files and try your suggestion. Hopefully I’ll get a more updated version. Thanks again. I’ll work on it and let you know how it goes.