Eclipse freeglut c++

Z
  • 23 Rugp '12

Sveiki,
mokausi programuoti naudojant freeglut ir c++. Šiuo metu rašau kodą naudodamas Geany, o kompiliuoju naudodamas makefile

CC = g++
CFLAGS = -Wall -std=c++0x
PROG = snake
SRCS = snake_gl.cpp element.cpp field.cpp snake.cpp time.cpp
LIBS = -lglut -lGLU

all: $(PROG)

$(PROG):    $(SRCS)
    $(CC) $(CFLAGS) -o $(PROG) $(SRCS) $(LIBS)

clean:
    rm -f $(PROG)

bet nusprendžiau pereiti ant galingesnės IDE ir pasirinkau eclipse. Diegiant eclipse ir nustatant projektą naudojausi internete rasta informacija. Išbandžiau su ten pateiktu OpenGL kodo pavyzdžių ir viskas veikė. Tad nusprendžiau perkelti savo parašyta programą į eclipse. Visi failai sėkmingai susikompiliavo į .o failus. Bet bandant juos sujungti gaunu klaidos pranešimą, kad nerandamas -lGLUT.

Building target: snake_freeglut
Invoking: GCC C++ Linker
g++ -o "snake_freeglut" ./element.o ./field.o ./snake.o ./snake_gl.o ./time.o -lGLUT -lGLU
/usr/bin/ld: cannot find -lGLUT
collect2: error: ld returned 1 exit status
make: * [snake_freeglut] Error 1

Build Finished

Projekto nustatimuose "Libreries" nurodyta kad reikia naudoti GLUT ir GLU. Kadangi viskas veikia naudojant make failą, viskas įdiegta teisingai.

Ubuntu 12.04 (precise) 64-bit
Branduolys Linux 3.2.0-29-generic
GNOME 3.4.2
Eclipse Version 3.7.2
Build id: I20110613-1736

S
Shookees
Paulius
  • 23 Rugp '12

Pats su OpenGL programavimu nelabai apsiemu, bet ar pateikus bibliotekas jas abi randa, ar tinkamai įrašytas GLUT? t.y. nors jei pavyzdžiai pavykdavo, bet gal programėlės išsisukdavo su GLU funkcionalumu (kaip supratau GLUT yra utility tools'as prie GLU?)?

Z
  • 24 Rugp '12

@Shookees rašė:
Pats su OpenGL programavimu nelabai apsiemu, bet ar pateikus bibliotekas jas abi randa, ar tinkamai įrašytas GLUT? t.y. nors jei pavyzdžiai pavykdavo, bet gal programėlės išsisukdavo su GLU funkcionalumu (kaip supratau GLUT yra utility tools'as prie GLU?)?

Su make failu kuri pateikiau mano programa susikompiliuoja ir veikia. Todėl manau, kad GLUT instaliuotas teisingai, nors OpenGL mokausi dar tik 2 - 3 savaites tai daug dar ko nežinau. Ji neveikia tik kai bandau kompiliuoti per eclipse. Tad spėjų, kad problemos kažkur su eclipse.
Makefile nuo eclipse skiriasi tuo, kad eclipse naudoja papildomus flagus kurių niekada nesu matęs ir tuo, kad ji sukompiliuoja .o failus su viena komanda, o juos sujungia kita komanda. Kai mano make failas viska padaro su viena komanda.

P.S. dabar berašydamas šia žinutę pastebėjau dar viena skirtumą tarp make failo ir eclipse. Pas mane make faile naudojų -lglut -lglu, o eclipsėje -lGLUT -lGLU. Tai nusprendžiau pervadinti ir eclipsėje į mažąsias raides. Pakeitus į -lglut -lglu, glut rado, bet nerado glu. Tada pakeičiau į -lglut -lGLU ir susikompiliavo sėkmingai. Be jokių klaudų. Naudojant Debug etapą.

Building target: snake_freeglut
Invoking: GCC C++ Linker
g++  -o "snake_freeglut"  ./element.o ./field.o ./snake.o ./snake_gl.o ./time.o   -lglut -lGLU
Finished building target: snake_freeglut

Tačiau pereinant į Release etapą gavau visa krūva naujų klaidų pranešimų.

Building target: snake_freeglut
Invoking: GCC C++ Linker
g++  -o "snake_freeglut"  ./element.o ./field.o ./snake.o ./snake_gl.o ./time.o   
./snake_gl.o: In function `update(int)':
snake_gl.cpp:(.text+0x1a): undefined reference to `glutPostRedisplay'
snake_gl.cpp:(.text+0x4e): undefined reference to `glutTimerFunc'
./snake_gl.o: In function `handleResize(int, int)':
snake_gl.cpp:(.text+0x79): undefined reference to `glViewport'
snake_gl.cpp:(.text+0x83): undefined reference to `glMatrixMode'
snake_gl.cpp:(.text+0x88): undefined reference to `glLoadIdentity'
snake_gl.cpp:(.text+0xb5): undefined reference to `glOrtho'
snake_gl.cpp:(.text+0xbf): undefined reference to `glMatrixMode'
./snake_gl.o: In function `initRendering()':
snake_gl.cpp:(.text+0x231): undefined reference to `glClearColor'
snake_gl.cpp:(.text+0x23b): undefined reference to `glMatrixMode'
snake_gl.cpp:(.text+0x240): undefined reference to `glLoadIdentity'
./snake_gl.o: In function `drawCube(int*)':
snake_gl.cpp:(.text+0x2c5): undefined reference to `glColor3f'
snake_gl.cpp:(.text+0x2cf): undefined reference to `glBegin'
snake_gl.cpp:(.text+0x32d): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0x36c): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0x3a9): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0x3c7): undefined reference to `glVertex3f'
./snake_gl.o: In function `drawBoard()':
snake_gl.cpp:(.text+0x4d0): undefined reference to `glColor3f'
snake_gl.cpp:(.text+0x4da): undefined reference to `glBegin'
snake_gl.cpp:(.text+0x546): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0x563): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0x582): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0x59d): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0x5a2): undefined reference to `glEnd'
snake_gl.cpp:(.text+0x5b5): undefined reference to `glColor3f'
snake_gl.cpp:(.text+0x5bf): undefined reference to `glBegin'
snake_gl.cpp:(.text+0x5d5): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0x5ee): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0x607): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0x620): undefined reference to `glVertex3f'
./snake_gl.o: In function `output(int, int, std::string)':
snake_gl.cpp:(.text+0x63d): undefined reference to `glRasterPos2f'
snake_gl.cpp:(.text+0x645): undefined reference to `glutBitmapHelvetica12'
./snake_gl.o: In function `statistic()':
snake_gl.cpp:(.text+0x653): undefined reference to `glutBitmapHelvetica12'
snake_gl.cpp:(.text+0x663): undefined reference to `glutBitmapHeight'
snake_gl.cpp:(.text+0x682): undefined reference to `glColor3f'
snake_gl.cpp:(.text+0x6f9): undefined reference to `glRasterPos2f'
snake_gl.cpp:(.text+0x703): undefined reference to `glutBitmapHelvetica12'
snake_gl.cpp:(.text+0x708): undefined reference to `glutBitmapString'
snake_gl.cpp:(.text+0x7a6): undefined reference to `glRasterPos2f'
snake_gl.cpp:(.text+0x7b0): undefined reference to `glutBitmapHelvetica12'
snake_gl.cpp:(.text+0x7b5): undefined reference to `glutBitmapString'
snake_gl.cpp:(.text+0x87b): undefined reference to `glRasterPos2f'
snake_gl.cpp:(.text+0x888): undefined reference to `glutBitmapHelvetica12'
snake_gl.cpp:(.text+0x88d): undefined reference to `glutBitmapString'
snake_gl.cpp:(.text+0x947): undefined reference to `glRasterPos2f'
snake_gl.cpp:(.text+0x954): undefined reference to `glutBitmapHelvetica12'
snake_gl.cpp:(.text+0x959): undefined reference to `glutBitmapString'
./snake_gl.o: In function `gameover()':
snake_gl.cpp:(.text+0xcd7): undefined reference to `glColor3f'
snake_gl.cpp:(.text+0xce4): undefined reference to `glBegin'
snake_gl.cpp:(.text+0xd0c): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0xd30): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0xd54): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0xd72): undefined reference to `glVertex3f'
snake_gl.cpp:(.text+0xd77): undefined reference to `glEnd'
snake_gl.cpp:(.text+0xd83): undefined reference to `glutBitmapHelvetica12'
snake_gl.cpp:(.text+0xd88): undefined reference to `glutBitmapLength'
snake_gl.cpp:(.text+0xd9e): undefined reference to `glColor3f'
snake_gl.cpp:(.text+0xdd9): undefined reference to `glRasterPos2f'
snake_gl.cpp:(.text+0xde3): undefined reference to `glutBitmapHelvetica12'
snake_gl.cpp:(.text+0xde8): undefined reference to `glutBitmapString'
./snake_gl.o: In function `drawScene()':
snake_gl.cpp:(.text+0xe6a): undefined reference to `glClear'
./snake_gl.o: In function `handleResize(int, int)':
snake_gl.cpp:(.text+0xc8): undefined reference to `glLoadIdentity'
./snake_gl.o: In function `handleMouse(int, int, int, int)':
snake_gl.cpp:(.text+0xf1): undefined reference to `glutIdleFunc'
snake_gl.cpp:(.text+0xf9): undefined reference to `glutPostRedisplay'
./snake_gl.o: In function `handleKeypress(unsigned char, int, int)':
snake_gl.cpp:(.text+0x169): undefined reference to `glutTimerFunc'
./snake_gl.o: In function `initRendering()':
snake_gl.cpp:(.text+0x271): undefined reference to `glOrtho'
./snake_gl.o: In function `drawCube(int*)':
snake_gl.cpp:(.text+0x3d0): undefined reference to `glEnd'
./snake_gl.o: In function `drawBoard()':
snake_gl.cpp:(.text+0x62b): undefined reference to `glEnd'
./snake_gl.o: In function `output(int, int, std::string)':
snake_gl.cpp:(.text+0x64b): undefined reference to `glutBitmapString'
./snake_gl.o: In function `drawScene()':
snake_gl.cpp:(.text+0xf09): undefined reference to `glutSwapBuffers'
./snake_gl.o: In function `restart_game()':
snake_gl.cpp:(.text+0xf65): undefined reference to `glutTimerFunc'
./snake_gl.o: In function `main':
snake_gl.cpp:(.text.startup+0xe): undefined reference to `glutInit'
snake_gl.cpp:(.text.startup+0x18): undefined reference to `glutInitDisplayMode'
snake_gl.cpp:(.text.startup+0x27): undefined reference to `glutInitWindowPosition'
snake_gl.cpp:(.text.startup+0x38): undefined reference to `glutInitWindowSize'
snake_gl.cpp:(.text.startup+0x47): undefined reference to `glutInitContextVersion'
snake_gl.cpp:(.text.startup+0x53): undefined reference to `glutCreateWindow'
snake_gl.cpp:(.text.startup+0x62): undefined reference to `glutDisplayFunc'
snake_gl.cpp:(.text.startup+0x6c): undefined reference to `glutReshapeFunc'
snake_gl.cpp:(.text.startup+0x76): undefined reference to `glutKeyboardFunc'
snake_gl.cpp:(.text.startup+0x80): undefined reference to `glutMouseFunc'
snake_gl.cpp:(.text.startup+0x92): undefined reference to `glutTimerFunc'
snake_gl.cpp:(.text.startup+0x97): undefined reference to `glutMainLoop'
collect2: error: ld returned 1 exit status
make: *** [snake_freeglut] Error 1

**** Build Finished ****

Tačiau Binaries failas sukuriamas. Jį paleidžiant išmetami tie patys klaidos pranešimai kaip aukščiau ir paklausia ar vis tiek norių paleisti. Jei vis tiek paleidžiu programa pasileidžia ir veikia.

Z
  • 24 Rugp '12

Iš čia galima parsisiųsti programos pirminį kodą
http://cplusplus.shinigami.lt/2012/08/2 ... nake-v1-1/

Z
  • 25 Rugp '12

Viskas veikia. Regis reikėjo bibliotekų vardus surašyti glut ir GLU. Bei ištrinti senus compiliuotus failus.
http://tjwallas.weebly.com/5/post/2010/ ... buntu.html

S
Shookees
Paulius
  • 25 Rugp '12

Sudominai visai su tuo opengl programavimu, galėtum gal pasidalinti gerais šaltiniais ar pdf'kėm? install

Z
  • 25 Rugp '12

Pradėjau skaityti čia http://www.videotutorialsrock.com/index.php apie OpenGL. Bet tik iki antros dalies. Kadangi nelabai supratau apie apšvietimą ir tekstūras. Gyliau pasidomėjus paaiškėjo, kad tai gan sudėtingos temos ir apie jas niekas internete detaliai nerašo.
Dabar skaitau šita knygą http://www.amazon.co.uk/OpenGL-Programm ... 635&sr=8-4
Norėjau pirkti šita http://www.amazon.co.uk/OpenGL-Programm ... 635&sr=8-3
kovo mėnesį buvau ją užsakęs ir žadėjo ant rudenio pristatyti. Bet belaukiant gaudavau vis daugiau ir daugiau žinučių apie knygos išleidimo atidėjimą. Kol nusprendžiau nelaukti ir skaityti pirmąją knyga (pdf formatu ).
Programavimo palengvinimui naudoju FreeGLUT kuris yra OpenGL biblioteka palengvinanti darbą su OpenGL ir papildanti keliomis galimybėmis. http://freeglut.sourceforge.net/
Žinau, kad dar daugiau galimybių suteikia SDL http://www.libsdl.org/ bet jis yra labiau skirtas jau programų kūrimui, o ne mokymuisi. http://stackoverflow.com/questions/2842 ... l-and-glut
Bet turbūt ateis ir jo eilė Kai išmoksiu 3D programavimo principų.