Jump to content

Recommended Posts

Posted

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?

Posted

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
Posted

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

Posted
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 ===
Posted

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

Posted

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

Posted

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.

  • 1 month later...
Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.