Baderous Posted April 6, 2009 at 05:15 PM Report #255529 Posted April 6, 2009 at 05:15 PM Estou com um problema no que toca a linkagem com o IDE CodeBlocks, que usa o MinGW. Encontrei este problema porque estou a tentar trabalhar com OpenGL em Windows e tenho que colocar aqui uns ficheiros em pastas específicas: Ficheiros: glut.h, glut32.lib, glut32.dll Ms Windows: glut.h: colocar na directoria dos includes em GL/ glut32.lib: colocar na directoria das libs glut32.dll: system (win98) ou system32 (Win NT ou XP) No pacote que saquei tinha lá estes ficheiros, mais um chamado glut.def. Depois coloquei-os nas seguintes pastas do MinGW: - glut.h: /include/GL - glut32.lib e glut.def: /lib - glut32.dll: esta coloquei na /Windows/system32 e na minGW/bin Ao executar o programa, obtenho os seguintes erros: g++.exe: -lm: linker input file unused because linking not done g++.exe: -lglut: linker input file unused because linking not done g++.exe: -lGL: linker input file unused because linking not done g++.exe: -lGLU: linker input file unused because linking not done Bem como uma série de erros a dizer que não reconhece as funções do OpenGL. As minhas configurações do CodeBlocks estão assim: http://img217.imageshack.us/my.php?image=flags.jpg http://img217.imageshack.us/my.php?image=tools.jpg Algo me diz que o problema está na 2ª imagem, na parte dos linkers, uma vez que a flag -lm também está a dar problemas. Alguém ajuda?
Baderous Posted April 7, 2009 at 07:06 PM Author Report #255749 Posted April 7, 2009 at 07:06 PM Então ninguém tem uma ideia? Já tentei mudar o linker para o ld.exe, mas também não dá. Aqui ficam os ficheiros que estão na pasta MinGW/bin: addr2line.exe ar.exe as.exe bison.exe bjam.exe bunzip2.exe bzip2.exe c++filt.exe cc.exe cpp.exe diff.exe diff3.exe dlltool.exe dllwrap.exe factor.exe flex.exe g++.exe gcc.exe gcov.exe gdb.exe gdbserver.exe glut32.dll gprof.exe grep.exe gzip.exe jpegtran.exe ld.exe libfreetype-6.dll libogg-0.dll libvorbis-0.dll libvorbisenc-2.dll libvorbisfile-3.dll make.exe mingwm10.dll nm.exe objcopy.exe objdump.exe oggdec.exe oggenc.exe ogginfo.exe patch.exe pngcheck.exe pngcrush.exe pngrewrite.exe ranlib.exe readelf.exe sdl-config SDL.dll SDL_mixer.dll sed.exe sha1sum.exe size.exe sort.exe split.exe strings.exe strip.exe tar.exe uniq.exe upx.exe vcut.exe vorbiscomment.exe wc.exe wget.exe windmc.exe windres.exe yacc
pedrosorio Posted April 7, 2009 at 07:10 PM Report #255750 Posted April 7, 2009 at 07:10 PM Experimenta desta forma: -lglut32 -lglu32 -lopengl32 Não respondo a dúvidas por mensagem.
Baderous Posted April 7, 2009 at 07:52 PM Author Report #255761 Posted April 7, 2009 at 07:52 PM Também não dá.
Triton Posted April 7, 2009 at 08:08 PM Report #255765 Posted April 7, 2009 at 08:08 PM Sempre que usei o Code::Blocks, não linkei como tu estás a fazer (adicionando flags directamente às opções extra do compilador). Se fores às opções do Linker, podes escolher os ficheiros que queres linkar directamente. Se precisares de mais indicações como fazer diz, porque tenho de instalar o C::B. 😞 <3 life
Baderous Posted April 7, 2009 at 08:34 PM Author Report #255772 Posted April 7, 2009 at 08:34 PM Apaguei as flags das opções do compilador e coloquei nas opções do linker a localização dos ficheiros glut32.lib e glut32.dll. http://img227.imageshack.us/my.php?image=linker.jpg Mas continua na mesma. Se pudesses dar umas dicas de como se faz, agradecia.
Triton Posted April 7, 2009 at 08:42 PM Report #255773 Posted April 7, 2009 at 08:42 PM Só precisas do ficheiro .lib. Qual é o erro que está a dar agora? <3 life
Baderous Posted April 7, 2009 at 08:57 PM Author Report #255780 Posted April 7, 2009 at 08:57 PM In function `_Z11renderScenev': undefined reference to `__imp__glClearColor' undefined reference to `__imp__glClear' undefined reference to `__imp__glLoadIdentity' undefined reference to `__imp__gluLookAt' undefined reference to `__imp__glRotatef' undefined reference to `__imp__glBegin' undefined reference to `__imp__glColor3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glColor3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glColor3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glColor3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' more undefined references to `__imp__glVertex3f' follow In function `_Z11renderScenev': undefined reference to `__imp__glColor3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glVertex3f' undefined reference to `__imp__glEnd' undefined reference to `_glutSwapBuffers' In function `_Z10changeSizeii': undefined reference to `__imp__glMatrixMode' undefined reference to `__imp__glLoadIdentity' undefined reference to `__imp__glViewport' undefined reference to `__imp__gluPerspective' undefined reference to `__imp__glMatrixMode' In function `glutCreateMenu_ATEXIT_HACK': c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.2.1-dw2\..\..\..\..\include\GL\glut.h|549|undefined reference to `___glutCreateMenuWithExit' o ao GLUT\CG-TP01\tp01.o||In function `glutCreateWindow_ATEXIT_HACK': c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.2.1-dw2\..\..\..\..\include\GL\glut.h|503|undefined reference to `___glutCreateWindowWithExit' o ao GLUT\CG-TP01\tp01.o||In function `glutInit_ATEXIT_HACK': c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.2.1-dw2\..\..\..\..\include\GL\glut.h|486|undefined reference to `___glutInitWithExit' In function `main': undefined reference to `_glutInitDisplayMode' undefined reference to `_glutInitWindowPosition' undefined reference to `_glutInitWindowSize' undefined reference to `_glutDisplayFunc' undefined reference to `_glutReshapeFunc' undefined reference to `_glutIdleFunc' undefined reference to `__imp__glEnable' undefined reference to `__imp__glEnable' undefined reference to `_glutMainLoop' ||=== Build finished: 48 errors, 0 warnings ===
Triton Posted April 7, 2009 at 09:10 PM Report #255784 Posted April 7, 2009 at 09:10 PM Não estás a linkar a biblioteca do OpenGL? Mas pelos erros também parece que não está a apanhar a do GLUT, que pela screenshot indicaste. Experimenta meter a do GL. 😞 <3 life
Baderous Posted April 7, 2009 at 10:01 PM Author Report #255791 Posted April 7, 2009 at 10:01 PM Hmm, estás a falar de alguma hipotética lib chamada opengl32.lib? É que se for, eu não tenho isso. Apenas tenho a libopengl32.a e não funciona com esta. g++.exe: C:\MinGW\lib\opengl32.lib: No such file or directory
Triton Posted April 7, 2009 at 10:14 PM Report #255794 Posted April 7, 2009 at 10:14 PM Sacaste qual versão do MinGW? 😞 <3 life
Baderous Posted April 7, 2009 at 10:21 PM Author Report #255797 Posted April 7, 2009 at 10:21 PM http://nuwen.net/mingw.html. Deve ter sido a versão 3.14.
Baderous Posted April 8, 2009 at 12:35 AM Author Report #255823 Posted April 8, 2009 at 12:35 AM Bem, o Triton esteve a ajudar-me e conseguiu criar um projecto no CodeBlocks, onde linkava as libs libopengl32.a e libglut32.a e aquilo funcionava. Agora não sei porquê não está a dar de novo. No entanto já descobri outra forma: https://users.cs.jmu.edu/bernstdh/web/common/help/cpp_mingw-glut-setup.php Tenho de criar um projecto, linkar a glut32.lib e colocar as flags -mwindows -lopengl32 -lglu32 e já funciona. Como já estou cansado, fica mesmo assim, se entretanto alguém se lembrar de brincar com isto para ver se descobre o porquê de já não conseguir da 1ª forma, que me avise.
OldCoder Posted May 8, 2009 at 09:44 AM Report #262287 Posted May 8, 2009 at 09:44 AM Perdoem-me ressuscitar um tópico com um mês, mas já tive problemas destes e mesmo que já tenhas visto isto, pelo menos fica aqui uma dica útil para os outros. Em primeiro lugar, se estás a usar a versão 8.02, devias considerar um upgrade para o código mais recente (Nightly Builds), que podes encontrar neste fórum. Neste momento, as nightly builds são muito superiores à versão 8.02 e já corrigiram imensos bugs críticos. É também possível que o C::B não saiba a localização das bibliotecas. Estás a usar variáveis globais? Desde que criei o hábito de declarar no C::B os paths das novas bibliotecas com o máximo de informação possível (ex., paths para "include" e "lib"), este problema nunca mais me ocorreu. É possível que, se utilizaste o Project Wizard, o C::B tenha chamado variáveis globais não utilizadas ao criar o projecto, e que os teus problemas venham daí. Para descobrir como usar esta facilidade, lê aqui.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now