User forums > Help
ld cannot find -lglu
(1/1)
escrifonife1:
I installed Code:: Block on Ubuntu 9.10 and when I try to compile some standard design Code:: Blocks OpenGL happens this error:
ld can not find-lXmu
In the menu Project> Build Options>> Linker Settings tab, when I add
"lglut" still giving the same error.
Sample code that I'm testing:
--- Code: ---#include <GL/glut.h>
#include <stdlib.h>
float vx = 1.0f;
float vy = 0.0f;
float vz = 0.0f;
float angulo = 0.0f;
// Prototipos das funções que serão chamadas pela Glut ( Callback )
void display(void);
void key(unsigned char key, int x, int y);
void idle(void);
void resize(int width, int height);
// Main padrão, o programa inicia aqui
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Programa Base");
// callbacks
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutIdleFunc(idle);
glClearColor(0.5,0.7,0.2,0);
glutMainLoop();
return EXIT_SUCCESS;
}
// Função que é chamada quando a janela é redimencionada
void resize(int width, int height)
{
const float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
glLoadIdentity();
}
// Função que é chamada quando for preciso mostrar ou atualizar a tela
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef (angulo, vx, vy, vz);
// Iniciando nosso triangulo
glBegin(GL_TRIANGLES);
glColor3d(255,0,0);
glVertex3f( 0.0f, 0.3f, 0.0f); // Vermelho
glColor3d(0,255,0);
glVertex3f(-0.3f,-0.3f, 0.0f); // Verde
glColor3d(0,0,255);
glVertex3f( 0.3f,-0.3f, 0.0f); // Azul
glEnd();
angulo += 0.50f;
if (angulo > 360.0f) angulo = 0.0f;
glutSwapBuffers();
}
// Função que é chamada quando uma tecla é apertada
void key(unsigned char key, int x, int y)
{
switch (key)
{
case 27 : // Caso aperte ESC sai do programa
{
exit(0);
break;
}
case 'x': // Caso aperte x rotaciona no eixo x
{
vx = 1.0f;
vy = 0.0f;
vz = 0.0f;
break;
}
case 'y': // Caso aperte y rotaciona no eixo y
{
vx = 0.0f;
vy = 1.0f;
vz = 0.0f;
break;
}
case 'z': // Caso aperte z rotaciona no eixo z
{
vx = 0.0f;
vy = 0.0f;
vz = 1.0f;
break;
}
}
glutPostRedisplay();
}
// Função que executa rotinas padrões da Glut
void idle(void)
{
glutPostRedisplay();
}
--- End code ---
Thanks for your attention.
by Tiago
Belo Horizonte - MG / Brasil
MortenMacFly:
--- Quote from: escrifonife1 on February 24, 2010, 02:50:42 am ---ld can not find-lXmu
--- End quote ---
You setup in the project options that you'll need to link against the library "Xmu". The linker cannot find it. Provide the correct path to the linker where it can find the library (project build options -> tab "Search directories").
--- Quote from: escrifonife1 on February 24, 2010, 02:50:42 am ---In the menu Project> Build Options>> Linker Settings tab, when I add
"lglut" still giving the same error.
--- End quote ---
Adding an additional different library does not help at all, obviously. Read the error message more carefully next time.
BTW: This hardly is a Code::Blocks error, but a linker error. So you are in the wrong forum btw... You topic might get locked sooner or later...
escrifonife1:
Sorry. Do not speak English as misspelled. I am translating with the Google translator, I'm Brazilian ....
The error you are giving is:
ld can not find -lglut
MortenMacFly:
--- Quote from: escrifonife1 on February 24, 2010, 01:35:23 pm ---ld can not find -lglut
--- End quote ---
Still, I already gave you the answer:
--- Quote from: MortenMacFly on February 24, 2010, 09:13:03 am ---The linker cannot find it. Provide the correct path to the linker where it can find the library (project build options -> tab "Search directories").
--- End quote ---
Surely I don't know whether you've "installed" the library at all.
escrifonife1:
Did it!!
I turned off the folder ".codeblocks" in /home/myuser and ran the Code::Blocks.
Thanks for the help.
Navigation
[0] Message Index
Go to full version