Advertisement

Problem with Opengl Textures

Started by December 06, 2004 01:56 PM
6 comments, last by Batman23 19 years, 11 months ago
Hi, I am trying to compile a project and I get the following linking errors: Linking... space.obj : error LNK2001: unresolved external symbol __imp__glBindTexture@8 space_main.obj : error LNK2001: unresolved external symbol __imp__glBindTexture@8 space.obj : error LNK2001: unresolved external symbol __imp__glGenTextures@8 Debug/Final Project.exe : fatal error LNK1120: 2 unresolved externals Error executing link.exe. Final Project.exe - 4 error(s), 0 warning(s) I have the following includes in my program: #include <windows.h> #include <gl/glut.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include "space.h" #include "bitmap_class.h" #pragma comment(lib, "opengl32.lib") #pragma comment(lib, "glu32.lib") #pragma comment(lib, "glaux.lib") How can I fix these errors? Any help is appreciated. Thanks.
Well, you need to include gl/gl.h, but this isn't gonna fix your problem. Does OpenGL32.lib exist? Post the code in space.cpp where you call glBindTexture.
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
Advertisement
gl.h should be included by glut.h.

Is OpenGL32.lib in your compilers lib search path? Do you call other OpenGL functions that are linking correctly?

Enigma
Here is the code wear I load the texture. As you can see there are other opengl functions that appear to be linking correctly. Also, OpenGL32.lib does exist. I am lost here.

// load a texture from a file
void CreateTexture(GLuint textureArray[], char *filename, int textureID)
{
CBitmap image;

if(!filename) // exit function if no filename is entered
return;

// load the bitmap and store the data
if(image.loadBMP(filename) == false) // if cannot load file exit function
return;

// Generate texture with associated textureID stored in the texture array
glGenTextures(1, &textureArray[textureID]);

// bind the texture to the texture array's index and init the texture
glBindTexture(GL_TEXTURE_2D, textureArray[textureID]);

// associate the texture with the texture ID
glTexImage2D(GL_TEXTURE_2D, 0, image.getChannels(), image.getWidth(), image.getHeight(),
0, GL_BGR_EXT, GL_UNSIGNED_BYTE, image.getLinePtr(0));

// build Mipmaps for the texture
gluBuild2DMipmaps(GL_TEXTURE_2D, image.getChannels(), image.getWidth(),
image.getHeight(), GL_BGR_EXT, GL_UNSIGNED_BYTE,
image.getLinePtr(0));

// set texture maps to use high quality linear mipmapping
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);


Which compiler are you using?
If, for instance, you're using Dev-C++, you have to include the libraries in your project options, because it doesn't support
#pragma comment(lib, "opengl32.lib")
I am using MS Visual C++ 6.0 and I have included opengl32.lib, glu32.lib, and glaux.lib in the object/library modules portion on the Link tab in project settings. However I still get the same errors. Any ideas?
Advertisement
As Enigma suggested, make sure you've got opengl32.lib in the lib folder of your compiler.
If the other functions are linking correctly, try downloading opengl32.lib again, perhaps the problem is with your version of the library.
I went and found a new download of opengl32.lib and my program now links successfully. Thanks for the help.

This topic is closed to new replies.

Advertisement