problem installing and using devil

I am new in texture mapping. I installed devil-1.7.8 in my system. Now I am trying to compile the following code:

#include <stdio.h>
#include <IL/il.h>
#include <IL/ilu.h>
#include <IL/ilut.h> //Used for loading the textures

#include “camera.h”

#if defined(WIN32)
#include <windows.h>
#endif

#if defined(WIN32) || defined(linux)
#include <GL/glut.h>
#elif defined(APPLE)
#include <GLUT/glut.h>
#endif

CCamera Camera;

GLfloat XRotated = 0.0;
GLfloat YRotated = 0.0;

GLuint Tex1, Tex2; // Textures

void InitTextures(void)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);

// Associate a variable to a image and load it

Tex1 = ilutGLLoadImage(“tex1.bmp”);
Tex2 = ilutGLLoadImage(“tex2.bmp”);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

}

void DrawCube(void)
{
//Draws a cube with two shaded, two one-colored and two textured faces
glBegin(GL_QUADS);
glColor3f(1.0,0.0,0.0);
//front:
glVertex3f(-0.5,-0.5,0.5);
glVertex3f(-0.5,0.5,0.5);
glVertex3f(0.5,0.5,0.5);
glVertex3f(0.5,-0.5,0.5);

//back:
  glColor3f(0.0,0.0,1.0);
  glVertex3f(-0.5,-0.5,-0.5);
  glVertex3f(0.5,-0.5,-0.5);
  glVertex3f(0.5,0.5,-0.5);
  glVertex3f(-0.5,0.5,-0.5);

//top:
  glColor3f(0.0,0.6,1.0);
  glVertex3f(-0.5,0.5,-0.5);
  glVertex3f(0.5,0.5,-0.5	);
  glColor3f(1.0,0.6,1.0);
  glVertex3f(0.5,0.5,0.5);
  glVertex3f(-0.5,0.5,0.5);

//bottom:
  glColor3f(0.0,0.6,0.0);
  glVertex3f(-0.5,-0.5,-0.5);
  glColor3f(0.6,0.6,0.6);
  glVertex3f(-0.5,-0.5,0.5);
  glColor3f(1.0,1.0,0.3);
  glVertex3f(0.5,-0.5,0.5);
  glColor3f(0.0,1.0,0.0);
  glVertex3f(0.5,-0.5,-0.5);

glEnd();
glEnable(GL_TEXTURE_2D);
glBindTexture( GL_TEXTURE_2D, Tex1);
glBegin(GL_QUADS);
//left:
glTexCoord2f(1.0,0.0);
glVertex3f(-0.5,-0.5,-0.5);
glTexCoord2f(1.0,1.0);
glVertex3f(-0.5,0.5,-0.5);
glTexCoord2f(0.0,1.0);
glVertex3f(-0.5,0.5,0.5);
glTexCoord2f(0.0,0.0);
glVertex3f(-0.5,-0.5,0.5);
glEnd();
//right:
glBindTexture( GL_TEXTURE_2D, Tex2);
glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0);
glVertex3f(0.5,-0.5,-0.5);
glTexCoord2f(1.0,0.0);
glVertex3f(0.5,-0.5,0.5);
glTexCoord2f(1.0,1.0);
glVertex3f(0.5,0.5,0.5);
glTexCoord2f(0.0,1.0);
glVertex3f(0.5,0.5,-0.5);
glEnd();
glDisable(GL_TEXTURE_2D);

}

void reshape(int x, int y)
{
if (y == 0 || x == 0) return;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40.0,(GLdouble)x/(GLdouble)y,0.5,20.0);

glMatrixMode(GL_MODELVIEW);
glViewport(0,0,x,y);
}

void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
Camera.Render();
glRotatef(YRotated,0.0,1.0,0.0);
// glRotatef(XRotated,1.0,0.0,0.0);
DrawCube();

glFlush();
glutSwapBuffers();

}
void KeyDown(unsigned char key, int x, int y)
{
switch (key)
{
case 27: //ESC
PostQuitMessage(0);
break;
case ‘a’:
Camera.RotateY(5.0);
Display();
break;
case ‘d’:
Camera.RotateY(-5.0);
Display();
break;
case ‘w’:
Camera.MoveForwards( -0.1 ) ;
Display();
break;
case ‘s’:
Camera.MoveForwards( 0.1 ) ;
Display();
break;
case ‘x’:
Camera.RotateX(5.0);
Display();
break;
case ‘y’:
Camera.RotateX(-5.0);
Display();
break;
case ‘c’:
Camera.StrafeRight(-0.1);
Display();
break;
case ‘v’:
Camera.StrafeRight(0.1);
Display();
break;
case ‘r’:
Camera.Move(F3dVector(0.0,0.1,0.0));
Display();
break;
case ‘f’:
Camera.Move(F3dVector(0.0,-0.1,0.0));
Display();
break;
case ‘b’:
if (glIsEnabled(GL_CULL_FACE) == GL_TRUE)
{
glDisable(GL_CULL_FACE);
glPolygonMode(GL_FRONT, GL_LINE);
glPolygonMode(GL_BACK, GL_FILL);
}
else
{
glEnable(GL_CULL_FACE);
glPolygonMode(GL_FRONT, GL_FILL);
}
Display();
break;
}
}

void Idle(void)
{
YRotated += 0.4;
XRotated += 0.4;
Display();
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(300,300);
glutCreateWindow(“Textures and BfC”);

// Handling images

ilInit();
iluInit();
ilutRenderer(ILUT_OPENGL);

glFrontFace(GL_CW); //Clockwise is front in “DrawCube()”
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
Camera.Move( F3dVector(0.0, 0.0, 3.0 ));
Camera.MoveForwards( 1.0 );
InitTextures();
glutDisplayFunc(Display);
glutReshapeFunc(reshape);
glutKeyboardFunc(KeyDown);
glutIdleFunc(Idle);
glutMainLoop();
return 0;
}

but I found the following error.

1>------ Build started: Project: Texture, Configuration: Debug Win32 ------
1>Compiling…
1>Camera.cpp
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdlib.h(371) : error C2381: ‘exit’ : redefinition; __declspec(noreturn) differs
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\gl\glut.h(146) : see declaration of ‘exit’
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdlib.h(371) : warning C4985: ‘exit’: attributes not present on previous declaration.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\gl\glut.h(146) : see declaration of ‘exit’
1>main.cpp
1>c:\users\shamima\documents\visual studio 2008\projects\project1 exture exture\main.cpp(79) : error C2664: ‘ilutGLLoadImage’ : cannot convert parameter 1 from ‘const char [9]’ to ‘wchar_t *’
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\shamima\documents\visual studio 2008\projects\project1 exture exture\main.cpp(80) : error C2664: ‘ilutGLLoadImage’ : cannot convert parameter 1 from ‘const char [9]’ to ‘wchar_t *’
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Generating Code…
1>Build log was saved at “file://c:\Users\shamima\Documents\Visual Studio 2008\Projects\Project1\Texture\Texture\Debug\BuildLog.htm”
1>Texture - 3 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Could any one help me identify the problem. Thanks.

const char [9]’ to 'wchar_t *

This is a problem of compiling with unicode but not correctly converting a string to unicode (usually using _T(“string”)).

error C2381: ‘exit’ : redefinition; __declspec(noreturn) differs

you need to resolve why you have 2 definitions of exit - check your include order.

I have fixed those errors. Now I am getting the following errors

Generating Code…
1>main.obj : error LNK2019: unresolved external symbol __imp__ilutGLLoadImage@4 referenced in function “void __cdecl InitTextures(void)” (?InitTextures@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__ilutRenderer@4 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__iluInit@0 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__ilInit@0 referenced in function _main
1>C:\Users\MYG741\Documents\Visual Studio 2010\Projects\Textures\Debug\Textures.exe : fatal error LNK1120: 4 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.26
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

How to make the program run? Please help me out.

Do you link your program with the correct import-libraries?

I am using MSVC 2010. In Linker->Additional dependencies , I put the following:DevIL.lib ;ILU.lib; ILUT.lib;

I have also added include and lib directories under VC++ directories.

Then I put the dll files under System32 and SysWOW64 directories.
I don’t under what else can be the linking problem.
Do I need to do anything else?

No. That should be it. Except you’re linking with the static Versions of il. As far as I know one Downloads the dynamic Versions (that is - the dlls and the Import libraries) from the Website when downloading the binaries, but I would double-check that. Otherwise I would not know what’s going wrong.

Thank you so much for prompt reply. I downloaded the following from the website: DevIL-SDK-x64-1.7.8: it has all the necessary files.

I managed to compile downloading 32-bit version, but when run the program I can’t view texture, it just shows a colored (not textured) plane. What could be the problem? Any one working with devil, please give me some suggestion what is going wrong.

I tried to figure out error using the following:

ILenum Error;

while ((Error = ilGetError()) != IL_NO_ERROR) {

   printf("%d: %s/n", Error, iluErrorString(Error)); 

}

It prints as follows:

“1291: invalid extension/n1290: could not open file/n”

I placed the image file in right directory. What does the eror mean? Could any one clarify?

“invalid extension” normally means it found the file but does not support the file type but it could also be that the filename you are passing is not correct and the extension doesn’t match a know image type.

The file extension is .bmp and it should be supported by devil. I can open the file to view it. Also I placed in proper folder where I put all c++ code. Then what could be the reason?