PDA

View Full Version : having problems under linux



andreaus44
12-21-2003, 04:54 PM
i'm new to programming in linux, and i'm having a problem getting kdevolop to work with OpenGl.. when i do a make on it.. it sees no errors but when i go to compile it it comes up with a million and one errors ..
and i know the code is legit because its out of the programmers manual openGl guide 1.4..
thanks joe

12-27-2003, 02:27 AM
You have to be more specific! It can be everything...
Show also source essential! I will check the next year!

andreaus44
01-01-2004, 07:47 AM
ok .. i'll be more specific(i actually have more time now to explain in full)

it seems more as if its not recognising my headers than anything else.. when compiling i get no errors.. but when i do a makefile it comes up with errors having to do with glut. i thought it may have been i didnt have glut installed.. so after reading some text on the internet on what to do to remedy this.. i installed mesa3d.. after doing this though i still had troubles.. if this doesnt give you enough info i can get back to you with my errors.. it will take me a bit(the girlfriend has plans) but..i think i can get back on by tonight and copy what my errors are..

andreaus44
01-06-2004, 09:30 AM
this is the source code i used ... i used 2 pages out of the opengl programmers guide 1.2 but like most of the programs
i keep getting the same type thing.. here is the code(i hope there are no legal conflicts considering that this off the pdf
file on opengls website..

#include <GL/gl.h>
#include <GL/glut.h>
#define drawOneLine(x1,y1,x2,y2) glBegin(GL_LINES); \
glVertex2f ((x1),(y1));glVertex2f((x2),(y2));glEnd();
void init(void){
glClearColor(0.0,0.0,0.0,0.0);
glShadeModel(GL_FLAT);
}
void display(void){
int i;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glEnable(GL_LINE_STIPPLE);
glLineStipple(1,0x0101);
drawOneLine(50.0,125.0,150.0,125.0);
glLineStipple(1,0x00FF);
drawOneLine(150.0,125.0,250.0,125.0);
glLineStipple(1,0x1C47);
drawOneLine(250.0,125.0,350.0,125.0);
glLineWidth(5.0);
glLineStipple(1,0x0101);
drawOneLine(50.0,100.0,150.0,100.0);
glLineStipple(1,0x00FF);
drawOneLine(150.0,100.0,250.0,100.0);
glLineStipple(1,0x1C47);
drawOneLine(250.0,100.0,350.0,100.0);
glLineWidth(1.0);
//
//
//
glLineStipple(1,0x1C47);
glBegin(GL_LINE_STRIP);
for(i=0;i<7;i++)
glVertex2f(50.0+((GLfloat)i*50.0),75.0);
glEnd();

for(i=0;i<6;i++){
drawOneLine(50.0+((GLfloat)i*50.0),50.0,
50.0+((GLfloat)i+1)*50.0,50.0);
}
glLineStipple(5,0x1C47);
drawOneLine(50.0,25.0,350.0,25.0);
glDisable(GL_LINE_STIPPLE);
glFlush();
}
void reshape(int w,int h)
{
glVeiwport(0,0,(GLsizei) w,(GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,(GLdouble)w,0.0,(GLdouble) h);
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(400,150);
glutInitWindowPosition(100,100);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
and here is what i get when i hit compile..

source='main.c' object='main.o' libtool=no \
depfile='.deps/main.Po' tmpdepfile='.deps/main.TPo' \
depmode=gcc3 /bin/sh ../admin/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I.. -O2 -O0 -g3 -Wall -c `test -f main.c &#0124; &#0124; echo './'`main.c
main.c: In function `reshape':
main.c:47: warning: implicit declaration of function `glVeiwport'
main.c:64:20: warning: no newline at end of file
*** success ***


this is my errors when i hit make on kdevelop.

gmake all-recursive
gmake[1]: Entering directory `/home/andreaus/project1sdl'
Making all in project1sdl
gmake[2]: Entering directory `/home/andreaus/project1sdl/project1sdl'
Making all in docs
gmake[3]: Entering directory `/home/andreaus/project1sdl/project1sdl/docs'
Making all in en
gmake[4]: Entering directory `/home/andreaus/project1sdl/project1sdl/docs/en'
gmake[4]: Nothing to be done for `all'.
gmake[4]: Leaving directory `/home/andreaus/project1sdl/project1sdl/docs/en'
gmake[4]: Entering directory `/home/andreaus/project1sdl/project1sdl/docs'
gmake[4]: Nothing to be done for `all-am'.
gmake[4]: Leaving directory `/home/andreaus/project1sdl/project1sdl/docs'
gmake[3]: Leaving directory `/home/andreaus/project1sdl/project1sdl/docs'
gmake[3]: Entering directory `/home/andreaus/project1sdl/project1sdl'
/bin/sh ../libtool --silent --mode=link gcc -O2 -O0 -g3 -Wall -o project1sdl main.o
main.o: In function `init':
/home/andreaus/project1sdl/project1sdl/main.c:6: undefined reference to `glClearColor'
/home/andreaus/project1sdl/project1sdl/main.c:7: undefined reference to `glShadeModel'
main.o: In function `display':
/home/andreaus/project1sdl/project1sdl/main.c:11: undefined reference to `glClear'
/home/andreaus/project1sdl/project1sdl/main.c:12: undefined reference to `glColor3f'
/home/andreaus/project1sdl/project1sdl/main.c:13: undefined reference to `glEnable'
/home/andreaus/project1sdl/project1sdl/main.c:14: undefined reference to `glLineStipple'
/home/andreaus/project1sdl/project1sdl/main.c:15: undefined reference to `glBegin'
/home/andreaus/project1sdl/project1sdl/main.c:15: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:15: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:15: undefined reference to `glEnd'
/home/andreaus/project1sdl/project1sdl/main.c:16: undefined reference to `glLineStipple'
/home/andreaus/project1sdl/project1sdl/main.c:17: undefined reference to `glBegin'
/home/andreaus/project1sdl/project1sdl/main.c:17: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:17: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:17: undefined reference to `glEnd'
/home/andreaus/project1sdl/project1sdl/main.c:18: undefined reference to `glLineStipple'
/home/andreaus/project1sdl/project1sdl/main.c:19: undefined reference to `glBegin'
/home/andreaus/project1sdl/project1sdl/main.c:19: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:19: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:19: undefined reference to `glEnd'
/home/andreaus/project1sdl/project1sdl/main.c:20: undefined reference to `glLineWidth'
/home/andreaus/project1sdl/project1sdl/main.c:21: undefined reference to `glLineStipple'
/home/andreaus/project1sdl/project1sdl/main.c:22: undefined reference to `glBegin'
/home/andreaus/project1sdl/project1sdl/main.c:22: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:22: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:22: undefined reference to `glEnd'
/home/andreaus/project1sdl/project1sdl/main.c:23: undefined reference to `glLineStipple'
/home/andreaus/project1sdl/project1sdl/main.c:24: undefined reference to `glBegin'
/home/andreaus/project1sdl/project1sdl/main.c:24: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:24: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:24: undefined reference to `glEnd'
/home/andreaus/project1sdl/project1sdl/main.c:25: undefined reference to `glLineStipple'
/home/andreaus/project1sdl/project1sdl/main.c:26: undefined reference to `glBegin'
/home/andreaus/project1sdl/project1sdl/main.c:26: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:26: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:26: undefined reference to `glEnd'
/home/andreaus/project1sdl/project1sdl/main.c:27: undefined reference to `glLineWidth'
/home/andreaus/project1sdl/project1sdl/main.c:31: undefined reference to `glLineStipple'
/home/andreaus/project1sdl/project1sdl/main.c:32: undefined reference to `glBegin'
/home/andreaus/project1sdl/project1sdl/main.c:34: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:35: undefined reference to `glEnd'
/home/andreaus/project1sdl/project1sdl/main.c:39: undefined reference to `glBegin'
/home/andreaus/project1sdl/project1sdl/main.c:39: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:39: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:39: undefined reference to `glEnd'
/home/andreaus/project1sdl/project1sdl/main.c:41: undefined reference to `glLineStipple'
/home/andreaus/project1sdl/project1sdl/main.c:42: undefined reference to `glBegin'
/home/andreaus/project1sdl/project1sdl/main.c:42: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:42: undefined reference to `glVertex2f'
/home/andreaus/project1sdl/project1sdl/main.c:42: undefined reference to `glEnd'
/home/andreaus/project1sdl/project1sdl/main.c:43: undefined reference to `glDisable'
/home/andreaus/project1sdl/project1sdl/main.c:44: undefined reference to `glFlush'
main.o: In function `reshape':
/home/andreaus/project1sdl/project1sdl/main.c:48: undefined reference to `glVeiwport'
/home/andreaus/project1sdl/project1sdl/main.c:49: undefined reference to `glMatrixMode'
/home/andreaus/project1sdl/project1sdl/main.c:50: undefined reference to `glLoadIdentity'
/home/andreaus/project1sdl/project1sdl/main.c:51: undefined reference to `gluOrtho2D'
main.o: In function `main':
/home/andreaus/project1sdl/project1sdl/main.c:55: undefined reference to `glutInit'
/home/andreaus/project1sdl/project1sdl/main.c:56: undefined reference to `glutInitDisplayMode'
/home/andreaus/project1sdl/project1sdl/main.c:57: undegmake[3]: Leaving directory `/home/andreaus/project1sdl/project1sdl'
gmake[2]: Leaving directory `/home/andreaus/project1sdl/project1sdl'
gmake[1]: Leaving directory `/home/andreaus/project1sdl'
fined reference to `glutInitWindowSize'
/home/andreaus/project1sdl/project1sdl/main.c:58: undefined reference to `glutInitWindowPosition'
/home/andreaus/project1sdl/project1sdl/main.c:59: undefined reference to `glutCreateWindow'
/home/andreaus/project1sdl/project1sdl/main.c:61: undefined reference to `glutDisplayFunc'
/home/andreaus/project1sdl/project1sdl/main.c:62: undefined reference to `glutReshapeFunc'
/home/andreaus/project1sdl/project1sdl/main.c:63: undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
gmake[3]: *** [project1sdl] Error 1
gmake[2]: *** [all-recursive] Error 1
gmake[1]: *** [all-recursive] Error 1
gmake: *** [all] Error 2
*** failed ***

what does this all mean??
do i not have opengl installed on my system?? am soposed to use a command line make/compile??\
would this have to do with the fact that i dont see anything related to opengl in my include directory??
also i picked up the programming linux games book aswell. i have sdl installed but when i try to use it i get the
same type of errors...
allright well later..

Martin_unique
01-06-2004, 12:23 PM
I don't see the line in your Makefile for including OpenGL headers & libraries, for example:

-I /usr/X11R6/include
-L /usr/X11R6/lib -lGL -lGLU

Do you have those somewhere in there ?

Martin

zen
01-06-2004, 12:40 PM
Well basically all those 'undefined reference to xxx' lines mean that you're calling function xxx from within your program but function xxx is not there, that is it is never defined. Of course it is not your job to define (that is write) all those gl functions but it is your job to link the appropriate libraties, GL, GLU anf GLUT in your case. Since you're using kdevelop read the docs on how to include a library in your project and include all 3 of the above libraries. Also change glVeiwport to glViewport in line 47 of main.c. That should do it, good luck.

01-16-2004, 11:12 AM
main.c: In function `reshape':
main.c:47: warning: implicit declaration of function `glVeiwport'
main.c:64:20: warning: no newline at end of file

---
You misspelled VIEW, glViewport
And add an extra newline at the end of the source file (just hit return)

---
/bin/sh ../libtool --silent --mode=link gcc -O2 -O0 -g3 -Wall -o project1sdl main.o
main.o: In function `init':
---
Don't forget to link in the right libraries,

-lGL -lglut -lglu
etc.