Author Topic: ld cannot find -lglu  (Read 8925 times)

Offline escrifonife1

  • Single posting newcomer
  • *
  • Posts: 3
ld cannot find -lglu
« on: February 24, 2010, 02:50:42 am »
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();
}


Thanks for your attention.


by Tiago
Belo Horizonte - MG / Brasil
« Last Edit: February 24, 2010, 02:54:55 am by escrifonife1 »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: ld cannot find -lglu
« Reply #1 on: February 24, 2010, 09:13:03 am »
ld can not find-lXmu
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").

In the menu Project> Build Options>> Linker Settings tab, when I add
"lglut" still giving the same error.
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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline escrifonife1

  • Single posting newcomer
  • *
  • Posts: 3
Re: ld cannot find -lglu
« Reply #2 on: February 24, 2010, 01:35:23 pm »
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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: ld cannot find -lglu
« Reply #3 on: February 24, 2010, 02:43:30 pm »
ld can not find -lglut
Still, I already gave you the answer:
The linker cannot find it. Provide the correct path to the linker where it can find the library (project build options -> tab "Search directories").
Surely I don't know whether you've "installed" the library at all.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline escrifonife1

  • Single posting newcomer
  • *
  • Posts: 3
Re: ld cannot find -lglu [Resolved]
« Reply #4 on: February 25, 2010, 01:09:15 am »
Did it!!
I turned off the folder ".codeblocks" in /home/myuser and ran the Code::Blocks.
Thanks for the help.