PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : opengl, wie compiliert man das?



doomcalyptica
09-07-2005, 20:56
hallo,


#include <gl.h> //opengl
#include <glu.h> //opengl ulitiy
#include <glut.h> //opengl ulitiy toolkit

void display() {
glClear(LG_COLOR_BUFFER_BIT); //löscht erstmal alle farbinformationen
glPoligonMode(GL_FRONT,GL_FILL); //zeichen der sichtbaren objekte
glPolygonMode(GL_BACK,GL_LINE); //zeichnen der verdeckten oobjekte
glLoadIdentity();
gluLookAt(0.0,10.0,10.0 //position des boebachters
,0.0,0.0,0.0 //worauf zentriert ?
,0.0,1.0,0.0); //vektor nach oben
glColor4f(1.0,0.0,0.0,1.0); //rot mit transparentz

glBegin(GL_LINES);
glVertex3f(0.0,0.0,0.0);
glVertex3f(1.0,0.0,0.0);
glVertex3f(0.0,0.0,0.0);
glVertex3f(0.0,0.0,1.0);
glEnd();

glTranslate(0.0,0.0,2.0);

glBegin(GL_TRIANGLES);
glVertex3f( 0.0, 0.0, 0.0);
glVertex3f( 1.0, 1.0, 0.0);
glVertex3f(-1.0, 1.0, 0.0);
glVertex3f( 0.0, 0.0, 0.0);
glVertex3f( 1.0, -1.0, 0.0);
glVertex3f(-1.0, -1.0, 0.0);
glEnd();

glTranslatef(0.0,0.0,-7.0);
glutWireSphere(1.0,16,16);

glFlush();
}

int main(int argc, char**argv) {
glutInit(&argc,argv); //initialisierung
glutInitWindowSize(300,300); //fenstergroese
glutInitWindowPosition(0,0); //fensterpostion
glutCreatWindow("tut 1 mit opengl"); //name des fensters

glutDisplayFunc(display); //zeigt auf funktion display
glClearColor(0.0,0.0,0.0,0.0); //es soll mit schwarz gelöscht werden

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerpective(45.0,1.0,1.0,100.0);

glMatrixMode(GL_MODELVIEW);
gluMainLoop();

return 0;
}



ich wollte da sprobgramm mit gcc opengl1.c -o open1 ürbersetzen, leider gfehts schief:


doom@workstation2:~/c/opengl$ gcc opengl1.c -o open1
opengl1.c:1:57: gl.h: No such file or directory
opengl1.c:2:64: glu.h: No such file or directory
opengl1.c:3:72: glut.h: No such file or directory
opengl1.c: In function `display':
opengl1.c:6: error: `LG_COLOR_BUFFER_BIT' undeclared (first use in this function)
opengl1.c:6: error: (Each undeclared identifier is reported only once
opengl1.c:6: error: for each function it appears in.)
opengl1.c:7: error: `GL_FRONT' undeclared (first use in this function)
opengl1.c:7: error: `GL_FILL' undeclared (first use in this function)
opengl1.c:8: error: `GL_BACK' undeclared (first use in this function)
opengl1.c:8: error: `GL_LINE' undeclared (first use in this function)
opengl1.c:15: error: `GL_LINES' undeclared (first use in this function)
opengl1.c:24: error: `GL_TRIANGLES' undeclared (first use in this function)
opengl1.c: In function `main':
opengl1.c:48: error: `GL_PROJECTION' undeclared (first use in this function)
opengl1.c:52: error: `GL_MODELVIEW' undeclared (first use in this function)
doom@workstation2:~/c/opengl$
die fehler resultieren vermutlich darauf, das die drei header nicht gefunden werden
opengl1.c:1:57: gl.h: No such file or directory
opengl1.c:2:64: glu.h: No such file or directory
opengl1.c:3:72: glut.h: No such file or directory
muss ich die nachnstallieren ?
oder sind bei scho standart drauf (mit gcc)

doomcalyptica
09-07-2005, 22:14
scheinbar is es schon drauf:
/usr/X11R6/include/GL/gl.h
/usr/X11R6/include/GL/glu.h
/usr/X11R6/include/GL/glut.h
wie binde ich das nun in mein programm ein und übeerrsestzre es mit gcc ?

locus vivendi
10-07-2005, 09:45
Du musst schon deinem Compiler sagen, dass er in /usr/X11R6/include bzw. /usr/X11R6/include/GL suchen soll. Also z.B. so
gcc -I/usr/X11R6/include/GL ...

doomcalyptica
10-07-2005, 10:58
hmm, jetz hat er zwar die header gefunden, leider findet er die richtigen funktionen nicht :/


oom@workstation2:~/c/opengl$
doom@workstation2:~/c/opengl$ gcc -I/usr/X11R6/include/ opengl1.c -o open1
/tmp/cc0GHVoV.o(.text+0xf): In function `display':
: undefined reference to `glClear'
/tmp/cc0GHVoV.o(.text+0x24): In function `display':
: undefined reference to `glPolygonMode'
/tmp/cc0GHVoV.o(.text+0x39): In function `display':
: undefined reference to `glPolygonMode'
/tmp/cc0GHVoV.o(.text+0x41): In function `display':
: undefined reference to `glLoadIdentity'
/tmp/cc0GHVoV.o(.text+0xb5): In function `display':
: undefined reference to `gluLookAt'
/tmp/cc0GHVoV.o(.text+0xd5): In function `display':
: undefined reference to `glColor4f'
/tmp/cc0GHVoV.o(.text+0xe2): In function `display':
: undefined reference to `glBegin'
/tmp/cc0GHVoV.o(.text+0xff): In function `display':
: undefined reference to `glVertex3f'
/tmp/cc0GHVoV.o(.text+0x11c): In function `display':
: undefined reference to `glVertex3f'
/tmp/cc0GHVoV.o(.text+0x139): In function `display':
: undefined reference to `glVertex3f'
/tmp/cc0GHVoV.o(.text+0x156): In function `display':
: undefined reference to `glVertex3f'
/tmp/cc0GHVoV.o(.text+0x15e): In function `display':
: undefined reference to `glEnd'
/tmp/cc0GHVoV.o(.text+0x18a): In function `display':
: undefined reference to `glTranslate'
/tmp/cc0GHVoV.o(.text+0x197): In function `display':
: undefined reference to `glBegin'
/tmp/cc0GHVoV.o(.text+0x1b4): In function `display':
: undefined reference to `glVertex3f'
/tmp/cc0GHVoV.o(.text+0x1d1): In function `display':
: undefined reference to `glVertex3f'
/tmp/cc0GHVoV.o(.text+0x1ee): In function `display':
: undefined reference to `glVertex3f'
/tmp/cc0GHVoV.o(.text+0x20b): In function `display':
: undefined reference to `glVertex3f'
/tmp/cc0GHVoV.o(.text+0x228): In function `display':
: undefined reference to `glVertex3f'
/tmp/cc0GHVoV.o(.text+0x245): more undefined references to `glVertex3f' follow
/tmp/cc0GHVoV.o(.text+0x24d): In function `display':
: undefined reference to `glEnd'
/tmp/cc0GHVoV.o(.text+0x267): In function `display':
: undefined reference to `glTranslatef'
/tmp/cc0GHVoV.o(.text+0x27f): In function `display':
: undefined reference to `glutWireSphere'
/tmp/cc0GHVoV.o(.text+0x287): In function `display':
: undefined reference to `glFlush'
/tmp/cc0GHVoV.o(.text+0x2a8): In function `main':
: undefined reference to `glutInit'
/tmp/cc0GHVoV.o(.text+0x2bd): In function `main':
: undefined reference to `glutInitWindowSize'
/tmp/cc0GHVoV.o(.text+0x2cc): In function `main':
: undefined reference to `glutInitWindowPosition'
/tmp/cc0GHVoV.o(.text+0x2dc): In function `main':
: undefined reference to `glutCreatWindow'
/tmp/cc0GHVoV.o(.text+0x2ec): In function `main':
: undefined reference to `glutDisplayFunc'
/tmp/cc0GHVoV.o(.text+0x30c): In function `main':
: undefined reference to `glClearColor'
/tmp/cc0GHVoV.o(.text+0x31c): In function `main':
: undefined reference to `glMatrixMode'
/tmp/cc0GHVoV.o(.text+0x324): In function `main':
: undefined reference to `glLoadIdentity'
/tmp/cc0GHVoV.o(.text+0x359): In function `main':
: undefined reference to `gluPerpective'
/tmp/cc0GHVoV.o(.text+0x369): In function `main':
: undefined reference to `glMatrixMode'
/tmp/cc0GHVoV.o(.text+0x371): In function `main':
: undefined reference to `gluMainLoop'
collect2: ld returned 1 exit status
doom@workstation2:~/c/opengl$
mein source:


#include <GL/gl.h> //opengl
#include <GL/glu.h> //opengl ulitiy
#include <GL/glut.h> //opengl ulitiy toolkit

void display() {
glClear(GL_COLOR_BUFFER_BIT); //löscht erstmal alle farbinformationen
glPolygonMode(GL_FRONT,GL_FILL); //zeichen der sichtbaren objekte
glPolygonMode(GL_BACK,GL_LINE); //zeichnen der verdeckten oobjekte
glLoadIdentity();
gluLookAt(0.0,10.0,10.0 //position des boebachters
,0.0,0.0,0.0 //worauf zentriert ?
,0.0,1.0,0.0); //vektor nach oben
glColor4f(1.0,0.0,0.0,1.0); //rot mit transparentz

glBegin(GL_LINES);
glVertex3f(0.0,0.0,0.0);
glVertex3f(1.0,0.0,0.0);
glVertex3f(0.0,0.0,0.0);
glVertex3f(0.0,0.0,1.0);
glEnd();

glTranslate(0.0,0.0,2.0);

glBegin(GL_TRIANGLES);
glVertex3f( 0.0, 0.0, 0.0);
glVertex3f( 1.0, 1.0, 0.0);
glVertex3f(-1.0, 1.0, 0.0);
glVertex3f( 0.0, 0.0, 0.0);
glVertex3f( 1.0, -1.0, 0.0);
glVertex3f(-1.0, -1.0, 0.0);
glEnd();

glTranslatef(0.0,0.0,-7.0);
glutWireSphere(1.0,16,16);

glFlush();
}

int main(int argc, char**argv) {
glutInit(&argc,argv); //initialisierung
glutInitWindowSize(300,300); //fenstergroese
glutInitWindowPosition(0,0); //fensterpostion
glutCreatWindow("tut 1 mit opengl"); //name des fensters

glutDisplayFunc(display); //zeigt auf funktion display
glClearColor(0.0,0.0,0.0,0.0); //es soll mit schwarz gelöscht werden

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerpective(45.0,1.0,1.0,100.0);

glMatrixMode(GL_MODELVIEW);
gluMainLoop();

return 0;
}

bischi
10-07-2005, 11:11
Vielleicht hilft dir der weiter:

http://mrunix.de/forums/showthread.php?t=39352

MfG Bischi

doomcalyptica
10-07-2005, 11:12
doom@workstation2:~/c/opengl$ gcc -I/usr/X11R6/include/ -lGL opengl1.c -o open1
/tmp/ccf4UrYo.o(.text+0xb5): In function `display':
: undefined reference to `gluLookAt'
/tmp/ccf4UrYo.o(.text+0x18a): In function `display':
: undefined reference to `glTranslate'
/tmp/ccf4UrYo.o(.text+0x27f): In function `display':
: undefined reference to `glutWireSphere'
/tmp/ccf4UrYo.o(.text+0x2a8): In function `main':
: undefined reference to `glutInit'
/tmp/ccf4UrYo.o(.text+0x2bd): In function `main':
: undefined reference to `glutInitWindowSize'
/tmp/ccf4UrYo.o(.text+0x2cc): In function `main':
: undefined reference to `glutInitWindowPosition'
/tmp/ccf4UrYo.o(.text+0x2dc): In function `main':
: undefined reference to `glutCreatWindow'
/tmp/ccf4UrYo.o(.text+0x2ec): In function `main':
: undefined reference to `glutDisplayFunc'
/tmp/ccf4UrYo.o(.text+0x359): In function `main':
: undefined reference to `gluPerpective'
/tmp/ccf4UrYo.o(.text+0x371): In function `main':
: undefined reference to `gluMainLoop'
collect2: ld returned 1 exit status
doom@workstation2:~/c/opengl$
kk, mit linken wird das schon eher was ^^
allerdings gibt es kein -l glu oder so ... das findet er nich ... wie kann ich die definition von z.b. der funktion wie gluMainLoop dem compilier beibringen ?

doomcalyptica
10-07-2005, 11:17
mal ganz allgemein, wo finde ich ne liste von den linker files ?
wieso ?
damit ich weis, wie sie heißen, damit ich sie richtig einbinden kann ^^

peschmae
10-07-2005, 12:33
Da du Glut includest wirst du das wohl auch verwenden und entsprechend linken müssen...

Siehe auch den von Bischi erwähnten Thread.

MfG Peschmä

doomcalyptica
10-07-2005, 12:49
doom@workstation2:~/c/opengl$ gcc -I/usr/X11R6/include/ -lglut -lGL opengl1.c -o open1
/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/bin/ld: cannot find -lglut
collect2: ld returned 1 exit status
doom@workstation2:~/c/opengl$

hmm, irgendwie fehlt mir die library

doomcalyptica
10-07-2005, 13:10
ich nehm ma stark an, das ich das hier ziehen muss ^^
http://www.ibiblio.org/pub/packages/development/graphics/glut/

peschmae
10-07-2005, 13:47
Sollte es eigentlich für deine Distribution auch geben - das ist recht verbreitet. Ausserdem vermute ich du hast das schon drauf und er findet die bilbiothek nur nicht - weil sonst würde er vermutlich schon beim Includen quengeln wegen fehlender Headerdateien.

MfG Peschmä

doomcalyptica
10-07-2005, 14:10
so


root@workstation2:/usr# find -name lib
./doc/docbook-style-xsl-1.49/doc/lib
./doc/docbook-style-xsl-1.49/docsrc/lib
./doc/python-2.3.4/html/Python-Docs-2.3.4/lib
./lib
./lib/perl5/5.8.4/unicore/lib
./lib/mozilla-1.7/chrome/chatzilla/content/chatzilla/lib
./lib/j2sdk1.4.2_04/jre/lib
./lib/j2sdk1.4.2_04/lib
./lib/qt-3.3.2/lib
./src/linux-2.4.26/lib
./src/linux-2.4.26/arch/sh/lib
./src/linux-2.4.26/arch/arm/lib
./src/linux-2.4.26/arch/ppc/lib
./src/linux-2.4.26/arch/ppc/boot/lib
./src/linux-2.4.26/arch/i386/lib
./src/linux-2.4.26/arch/cris/lib
./src/linux-2.4.26/arch/ia64/lib
./src/linux-2.4.26/arch/m68k/lib
./src/linux-2.4.26/arch/mips/lib
./src/linux-2.4.26/arch/s390/lib
./src/linux-2.4.26/arch/sh64/lib
./src/linux-2.4.26/arch/alpha/lib
./src/linux-2.4.26/arch/s390x/lib
./src/linux-2.4.26/arch/ppc64/lib
./src/linux-2.4.26/arch/sparc/lib
./src/linux-2.4.26/arch/sparc64/lib
./src/linux-2.4.26/arch/mips64/lib
./src/linux-2.4.26/arch/parisc/lib
./src/linux-2.4.26/arch/x86_64/lib
./src/glut-3.5/lib
./i486-slackware-linux/lib
./X11R6/lib
./X11R6/lib/X11/locale/lib
./local/lib
./share/jed/lib
./share/xml/docbook/xsl-stylesheets-1.48/lib
./share/sgml/docbook/xsl-stylesheets-1.49-1/lib
./share/sgml/docbook/dsssl-stylesheets-1.59/lib
./share/sgml/docbook/dsssl-stylesheets-1.64/lib
./share/ghostscript/7.07/lib
./share/texmf/lib
./include/sp/lib

hir hab ich mal alle lib spezifischen ordner auflisten lassen, davon denke ich mal sind nur die folgenden für mein problem interresant:


./src/glut-3.5/lib
./i486-slackware-linux/lib
./X11R6/lib
./X11R6/lib/X11/locale/lib
./local/lib
wobei dieser ordner das paket ist, welches ich heruntergeladen hab alerdings nicht installieren konnte ..
und du has recht, @ peschmae, das glut zeugs ist drauf, leider kann das aber nicht mit meinem gcc compilier in verbindung gebracht werden ... mann muss es manuell machen, ich weis nur leider nicht wie ^^


cd /usr
root@workstation2:/usr/X11R6/lib# ls /usr/X11R6/lib/ | grep gl
libglsmap.a
libglut.so
libglut.so.3
libglut.so.3.7

ls /usr/i486-slackware-linux/lib/ | grep gl

ls /usr/X11R6/lib/X11/locale/lib/ | grep gl

root@workstation2:~# ls /usr/local/lib/ | grep gl
glib-2.0
libglib-2.0.la
libglib-2.0.so
libglib-2.0.so.0
libglib-2.0.so.0.301.0
libglib-2.0.so.0.600.4

jo, glut hat er nicht gefunden ...
außer in /usr/src/glut-3.5/ ...
wie kann ich die nun mit gcc einbinden ?
also
(also normal user in meinem fall doom):
cd ~/c/opengl/
gcc opengl1.c -o open1 -lgl <wie gehts weiter ?>

doomcalyptica
10-07-2005, 14:34
nur mit so einer zeile, kann ich die fehler auf ein minimum reduzieren ^^

gcc -o open1 -L/usr/src/glut-3.5/lib/ -L/usr/X11R6/lib opengl1.c -lGL -lGLU -lglut -lm -lX11 -lXmu
/tmp/ccwluOhk.o(.text+0x18a): In function `display':
: undefined reference to `glTranslate'
/tmp/ccwluOhk.o(.text+0x2dc): In function `main':
: undefined reference to `glutCreatWindow'
/tmp/ccwluOhk.o(.text+0x359): In function `main':
: undefined reference to `gluPerpective'
/tmp/ccwluOhk.o(.text+0x371): In function `main':
: undefined reference to `gluMainLoop'
collect2: ld returned 1 exit status
[/code]
ich hab trotzdem noch den eindrug, als ob gl, glu und glut fehlt ^^
oder zumindeast ein teil ...

mal ne andere frage:
ich hatte schon immer mit slackware probleme im bezug sourcen compilieren ... selbst, auf mein server, dort kann er nicht mal nen printf (welches ja zu standart C gehört) nicht linken ...
auf mein server und auf dem rechner, an dem ich grad sitze hab ich das gleiche system drauf auch in etwa die gleichen software pakete ...
is irgendwie strange wah ^^
mit was proggt ihr denn so ?

doomcalyptica
10-07-2005, 14:55
men /etc/ls.so.conf schaut so aus:


/usr/local/lib
/usr/X11R6/lib
/usr/i486-slackware-linux/lib
/opt/kde/lib
/usr/lib/qt/lib
/usr/src/glib-2.6.4
/usr/local

bischi
10-07-2005, 15:07
nur mit so einer zeile, kann ich die fehler auf ein minimum reduzieren ^^

gcc -o open1 -L/usr/src/glut-3.5/lib/ -L/usr/X11R6/lib opengl1.c -lGL -lGLU -lglut -lm -lX11 -lXmu
/tmp/ccwluOhk.o(.text+0x18a): In function `display':
: undefined reference to `glTranslate'
/tmp/ccwluOhk.o(.text+0x2dc): In function `main':
: undefined reference to `glutCreatWindow'
/tmp/ccwluOhk.o(.text+0x359): In function `main':
: undefined reference to `gluPerpective'
/tmp/ccwluOhk.o(.text+0x371): In function `main':
: undefined reference to `gluMainLoop'
collect2: ld returned 1 exit status
[/code]
ich hab trotzdem noch den eindrug, als ob gl, glu und glut fehlt ^^
oder zumindeast ein teil ...

mal ne andere frage:
ich hatte schon immer mit slackware probleme im bezug sourcen compilieren ... selbst, auf mein server, dort kann er nicht mal nen printf (welches ja zu standart C gehört) nicht linken ...
auf mein server und auf dem rechner, an dem ich grad sitze hab ich das gleiche system drauf auch in etwa die gleichen software pakete ...
is irgendwie strange wah ^^
mit was proggt ihr denn so ?


Sieht stark nach tippfehler aus:

createWindow anstatt creatwindow
perspective anstatt perpective...

Nimm mal die Fehler raus und schau weiter.

MfG Bischi

locus vivendi
10-07-2005, 17:23
Sieht stark nach tippfehler aus:

createWindow anstatt creatwindow
perspective anstatt perpective...

Nimm mal die Fehler raus und schau weiter.
Das ist einer der Gründe, warum ich grundsätzlich zu C++ rate: Da hätte schon der Compiler und nicht erst der Linker das Übersetzen verweigert, und der Fehler wäre schneller gefunden wurden. Allerdings
bin ich mir auch nicht sicher, ob man mit C99 nicht das Verhalten an C++ angepasst hätte. Der Gcc implementiert es jedenfalls nicht.