PDA

View Full Version : Uploading an image using DevIL: Linker errors



annette
01-27-2012, 08:02 AM
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 to `glfwSwapBuffers'
[Linker error] undefined reference to `glfwTerminate'

Kopelrativ
01-27-2012, 11:57 AM
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%2Fd ocs%2FDevIL%2520Manual.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.

marshats
01-28-2012, 09:28 AM
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

ugluk
01-28-2012, 03:05 PM
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.

Alfonse Reinheart
01-28-2012, 04:49 PM
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.

ugluk
01-28-2012, 05:23 PM
It is a wrapper around libpng, libjpeg, ... and you need to compile&link those.

Alfonse Reinheart
01-28-2012, 06:15 PM
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.

ugluk
01-29-2012, 07:06 AM
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.

Alfonse Reinheart
01-29-2012, 10:06 AM
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.

Kopelrativ
01-29-2012, 10:27 AM
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).

annette
01-30-2012, 10:17 AM
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.

annette
01-30-2012, 10:18 AM
I'm using Windows

annette
01-30-2012, 10:34 AM
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

marshats
01-30-2012, 12:47 PM
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

annette
01-30-2012, 02:35 PM
Thanks so much for this information. I'll try it immediately and let you know how it turns out. Thanks again.

annette
01-30-2012, 02:36 PM
By the way, I'm using dev-c++ in windows

Alfonse Reinheart
01-30-2012, 03:12 PM
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.

annette
01-30-2012, 03:28 PM
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.

marshats
01-30-2012, 03:49 PM
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

annette
01-30-2012, 04:05 PM
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.

annette
01-31-2012, 09:16 AM
It gave me an error message when I tried to download GLFW + openGL:
"The following files were not downloaded due to errors...
File http://www.filefactory.com/file/4d8061/ does not exist"

marshats
01-31-2012, 10:09 AM
Ok, then manually download the latest Binary archive for Windows glfw - Download (http://www.glfw.org/download.html) specifically the glfw-2.7.2.bin.WIN32.zip. Not the source download

Then use the lib-mingw build. You only need two files to be copied to where you installed Dev-Cpp. In my particular case that is "C:\Dev-Cpp" if you installed it somewhere else then change accordingly


copy glfw-2.7.2.bin.WIN32\include\GL\glfw.h C:\Dev-Cpp\include\GL
copy glfw-2.7.2.bin.WIN32\lib-mingw\libglfw.a C:\Dev-Cpp\lib

Then in the dev-cpp link parameters always make certain you have "-lglfw -lopengl32"

annette
01-31-2012, 11:11 AM
Thanks so much. All the glfw linker errors vanished like magic. But the other errors returned. Below is the compiler log. My Project-> Project Options-> Parameters-> Linker input currently looks like this:

-lglfw -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32 -ldevil
-lglew32
-lilu
-lilut
I put -llu and -lilut back because I was still getting the same errors without them. I also realized that the versions for the ilu, ilut and DevIL libraries and dll were different so deleted everyone of them, downloaded the latest version of DevIL and put those files in their correct places.
C:\Dev-Cpp\include\GL
C:\Dev-Cpp\include\IL
C:\Dev-Cpp\lib
C:\Windows\System32

I was expecting it to make a difference but it didn't.
FYI: I wanted to format the compiler log but I didn't see any options I could use to do so. I hope you're able to read it. Thanks.

Compiler: Default compiler
Building Makefile: "C:\Users\annette\Documents\Visual Studio 2010\Projects\Version2\Neutral - Copy (4)\Makefile.win"
Executing make...
make.exe -f "C:\Users\annette\Documents\Visual Studio 2010\Projects\Version2\Neutral - Copy (4)\Makefile.win" all
g++.exe -D__DEBUG__ neutral.o -o "Neutral.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib" -mwindows -lglfw -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32 -ldevil -lglew32 -lilu -lilut -g3

neutral.o(.text+0x11b): In function `Z9loadImagePKc':
C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:58: undefined reference to `_imp__ilGenImages@8'
neutral.o(.text+0x12b):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:60: undefined reference to `_imp__ilBindImage@4'
neutral.o(.text+0x13b):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:62: undefined reference to `_imp__ilLoadImage@4'
neutral.o(.text+0x158):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:69: undefined reference to `_imp__iluGetImageInfo@4'
neutral.o(.text+0x16b):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:72: undefined reference to `_imp__iluFlipImage@0'
neutral.o(.text+0x181):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:77: undefined reference to `_imp__ilConvertImage@8'
neutral.o(.text+0x194):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:82: undefined reference to `_imp__ilGetError@0'
neutral.o(.text+0x287):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:102: undefined reference to `_imp__ilGetData@0'
neutral.o(.text+0x297):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:102: undefined reference to `_imp__ilGetInteger@4'
neutral.o(.text+0x2aa):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:102: undefined reference to `_imp__ilGetInteger@4'
neutral.o(.text+0x2bd):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:102: undefined reference to `_imp__ilGetInteger@4'
neutral.o(.text+0x2d1):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:102: undefined reference to `_imp__ilGetInteger@4'
neutral.o(.text+0x31b):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:114: undefined reference to `_imp__ilGetError@0'
neutral.o(.text+0x374):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:119: undefined reference to `_imp__ilDeleteImages@8'
neutral.o(.text+0x614): In function `Z6initGLii':
C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:194: undefined reference to `_imp__iluGetInteger@4'
neutral.o(.text+0x62c):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:194: undefined reference to `_imp__iluGetInteger@4'
neutral.o(.text+0x644):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:194: undefined reference to `_imp__ilutGetInteger@4'
neutral.o(.text+0x68e):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:201: undefined reference to `_imp__ilutRenderer@4'
neutral.o(.text+0x698):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:202: undefined reference to `_imp__ilInit@0'
neutral.o(.text+0x69f):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:203: undefined reference to `_imp__iluInit@0'
neutral.o(.text+0x6a6):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:204: undefined reference to `_imp__ilutInit@0'
neutral.o(.text+0x6b4):C:/Users/annette/Documents/Visual Studio 2010/Projects/Version2/Neutral - Copy (4)/neutral.cpp:205: undefined reference to `_imp__ilutRenderer@4'
collect2: ld returned 1 exit status

make.exe: *** [Neutral.exe] Error 1

Execution terminated

ugluk
01-31-2012, 12:49 PM
anette, why not give stb_image a try? You can include it in your project without any hassle or downloading of libraries.

Try this:
- add the .c file to your project
- when including the library do this:

#ifndef STBI_HEADER_FILE_ONLY
# define STBI_HEADER_FILE_ONLY
#endif // STBI_HEADER_FILE_ONLY
#include "stb_image.c"


That's all! Enjoy! The sooner you forget about DevIL, the better.

annette
01-31-2012, 01:02 PM
I'll check it out. I just checked briefly and it looks like stb_image does not support .tiff files which I am using. I may have to convert my .tiff images to .jpeg first and then use it and see if it works. But I'll look into it. Thanks

ugluk
01-31-2012, 01:09 PM
Yeah, and there's a nifty library called >>tvmet<< for your vector needs :).

You can also convert to .png, if you don't want to lose quality of your images.

marshats
01-31-2012, 05:17 PM
DevIL is a good library to be able to use. It is good to suggest use of alternatives but it is also valuable to learn how to setup up the compiler tools. The common windows way of passing around a c-file (to avoid this library stuff) to every project can become overly cumbersome. Having compiled libraries in a standard shared location is a good paradigm to foster.

For dev-cpp, and any XYZ library, it is just a matter of getting the correct libXYZ.*a, header files, maybe a XYZ.dll, and specifying the link option -lXYZ. That's usually it. The question for me is why was it so simple on my setup to get glfw and devil working but not so for this user's post?

Back to the post, once you deleted the IL* files where exactly did you get the new ones to replace them? Did you download or use the zip file that contained the ones that "worked" before glfw was fixed?

ugluk
02-01-2012, 02:10 AM
DevIL is a good library to be able to use. It is good to suggest use of alternatives but it is also valuable to learn how to setup up the compiler tools. The common windows way of passing around a c-file (to avoid this library stuff) to every project can become overly cumbersome. Having compiled libraries in a standard shared location is a good paradigm to foster.For some reason many people are unwilling to make the investment of time to learn this. To them this is a command-line thing and they prefer using python or some other scripting language - a pity, many good potential C/C++ programmers are lost this way, I think.

The truth in my opinion is that IDEs don't really make things easier, people just need to learn the "command-line thing" or use some grand M$ product.

annette
02-01-2012, 07:15 AM
Back to the post, once you deleted the IL* files where exactly did you get the new ones to replace them? Did you download or use the zip file that contained the ones that "worked" before glfw was fixed?

I downloaded a new DevIL zip file from their website and used that. I didn't use the zip file that contained the DevIL files that worked before gllfw was fixed. I made this decision because even with the old DevIL, it still didn't work.

I tried to compile this program on another machine this morning. Since glew and glfw were not on that machine, I got one error message saying it could not find lglew and lglfw. So I put the header and library files for these two on the new machine and those errors went away. I did the same for lDevIL. Then I got an error message saying it could find lilu too. So I put the folder IL, containing il ilu and ilut in the "include" folder in Dev-cpp and put their library files in the "lib" folder. Then, all the past errors came back. This tells me the problem is with the il, ilu and ilut files. These files are in the IL folder in Dev-cpp folder. Should they be somewhere else? Am I right by including:

#include <IL/il.h>
#include <IL/ilu.h>
#include <IL/ilut.h

in my code?

I don't know what else I'm doing wrong. Under "Parameters" in Project Options, I have:
-lglfw -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32 -ldevil
-lglew32
-lilu
-lilut

In the "Directories" section:
Under "Library directories" I have: C:\Dev-Cpp\lib
Under "Include directories" I have C:\Dev-Cpp\include\GL
C:\Dev-Cpp\include\IL

In systems32 I have all the dlls for the various files in there. What else I am missing? Please help me with this one.

annette
02-01-2012, 07:21 AM
Also, this is how I have the header files set up in my program.

#include <iostream>
#include <windows.h>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib>

#include <GL/glew.h> // Include OpenGL headers
#include <GL/glfw.h> // Include OpenGL Framework headers

#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>

#define GLUT_USE_OPENGL // This MUST be defined before calling
//the DevIL headers or we don't get
//OpenGL functionality
#include <IL/il.h>
#include <IL/ilu.h>
#include <IL/ilut.h>

using namespace std;


Should they be arranged differently? I know for example,
#include <GL/glew.h> // Include OpenGL headers
#include <GL/glfw.h> // Include OpenGL Framework headers

must come before the IL header files. I'm just thinking of all possibilities right now.

annette
02-01-2012, 07:24 AM
By MS, did you mean Microsoft? Well, I could have used Visual Studio C++ but we are required to use Dev-C++ for this project.

annette
02-01-2012, 08:37 AM
Finally, I solved it. The program is compiling now. I found the solution from another post on www.codeproject.com. (http://www.codeproject.com) I went to Devpak.org and downloaded DevIL. You can google "devpak DevIL" and choose the "DevIL Library Version-Devpak repository" option. Then I opened my program in Dev-C++ and went to Tool->Package Manager-> and clicked on install. I followed the Wizard directions. It asked me to upload the package I had just downloaded. Once the installation was complete, DevIL was added to the packages in package manager. That's all I had to do. To verify that all the libraries were on my machine, I went to C:\Dev-cpp\lib

I saw all the ilu and ilut libraries: the object libraries and those ending in .a. I think the files ending in .a were the ones the compiler was looking for, and not the object library files. Extra DevIL files were added to the DevIL files that were already there.

Once I installed DevIL and compiled the program, all the errors went away. Now I can concentrate on getting the images to actually upload. Thank you all so much for helping. I hope this discussion will help someone else also. Thanks again.