Skip to main content
gamedev.net
🔒 Locked

Linker error with Dev-C++

Started by kman12 5 replies 1.4k views
Original Post
kman12
kman12
When trying to compile an OpenGL program, I always get the following error:

[Linker error] undefined reference to `glOrtho@24' 
I'm linking with -lopengl32. Does anyone know why this is happening? It's weird because I don't get any other errors with it, so it's not like I'm missing a library or anything. Do you think my opengl32.lib could be corrupted or something? [edit] I looked around and found out that opengl32.lib is distributed with the compiler. So I downloaded the latest version of the lib from the MingGW website, but it still has the same problem. Is this just an incomplete implementation of the API? Do I have to buy MSVC++ to get the "official Microsoft version?" thanks, kman [Edited by - kman12 on January 23, 2005 10:37:05 PM]
Drew_Benton
Drew_Benton
Try adding this:

-lglu32

- Drew
kman12
kman12
Tried that, and -lglut32 and -lglut. Then I tried linking against every lib in the lib directory, and it still didnt work. I think something is wrong. It's so much easier to develop in linux... If only it were so simple in windows.

kman
Drew_Benton
Drew_Benton
Quote:
Original post by kman12
Tried that, and -lglut32 and -lglut. Then I tried linking against every lib in the lib directory, and it still didnt work. I think something is wrong. It's so much easier to develop in linux... If only it were so simple in windows.

kman


Are you using the most recent version of Dev-CPP? Dev-C++ 5.0 beta 9 (4.9.9.1) (7.6 MB) with Mingw/GCC 3.3.1 Try doing a clean reinstall of that. Also can you post your code?
kman12
kman12
Tried a complete uninstall then reinstall, but to no avail. Maybe tomorrow I'll try it on another computer. Here's the relevent section of code, but I don't think it matters since it compiled fine in Linux.

void update_map() {	int i;	int j;	int cell;		glMatrixMode(GL_PROJECTION);	glLoadIdentity();	glOrtho(0, 640, 480, 0, -1, 1);		//for loop through all the tiles, drawing them one by one	for(i = 0; i < 40; i++) {		for(j = 0; j < 30; j++) {			cell = (int) maparray[a_index(i + screenx, j + screeny, mapwidth, mapheight)].tiletype;			glBindTexture( GL_TEXTURE_2D, texture[cell] );			glBegin(GL_QUADS);				glTexCoord2i(1, 0); glVertex3i(i * 16,j * 16,0);				glTexCoord2i(0, 0); glVertex3i(i * 16 + 16,j * 16,0);				glTexCoord2i(0, 1); glVertex3i(i * 16 + 16,j * 16 + 16,0);				glTexCoord2i(1, 1); glVertex3i(i * 16,j * 16 + 16,0);			glEnd();		}	}	SDL_GL_SwapBuffers();}
Drew_Benton
Drew_Benton
I'm sure it is just that computer. What you need to do is this:

* Search for "libopengl32.a".
* Instead of linking -lopengl32, link this file, whereever you can find it in your Dev-CPP folder.

I was able to compile that code just fine, so either the .a file (Dev-CPP's .lib file) doesn't exist, or is in a different location. Another thing, what is the path of your Dev-CPP folder? I know that I had to make mine:
"X:\Dev-Cpp\" because Dev-CPP does not work well with spaces in the folder paths, maybe that is a problem as well.

- Drew
kman12
kman12
I tried linking directly to the file, still didn't work. Whatever. I'll just try it on a different computer tomorrow.

thanks,
kman

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.