PDA

View Full Version : linker error about glut in dev C++



Chiyu Wang
04-13-2005, 11:45 AM
[Linker error] undefined reference to `glClear@4'
[Linker error] undefined reference to `glColor3f@12'

I had the code:

#include <cstdlib>
#include <iostream>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
//#include <libiberty.h>
using namespace std;

int main(int argc, char *argv[])
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25,0.25,0.0);
glVertex3f(0.75,0.25,0.0);
glVertex3f(0.75,0.75,0.0);
glVertex3f(0.25,0.75,0.0);
glEnd();
glFlush();
return 0;
}

I don't know where is the problem

I have copied the glut.h to the ../GL/
glut32.dll and glut.dll to ../system32
glut32.lib and glut.lib to ../lib

dorbie
04-13-2005, 03:53 PM
Looks like a namespace issue with C++ code calling C, but I wouldn't expect it with extern "C" {} blocks around those headers if it's included.

The issue is gl.h, take a look and make sure it has extern "C" { at the top of teh file.

Hmm.... it may be the way your glut has been compiled and your lib cant resolve the names when linking, I'd be somewhat surprised though.

Did you compile glut? Did you get it as a binary compiled by another development system?

Chiyu Wang
04-14-2005, 01:48 AM
I download the files from opengl.org
and the file had been already compiled .
So I don't know if it is compiled at other systems.

Pantelwolf
04-18-2005, 05:41 AM
I had the same problem
On Dev C++ goto the project options menu and
add the switches -lopengl32 or so
as is explained in the first lines in readme.txt
on folder /include/gl/