Menu

linked problem

2004-05-03
2012-09-26
  • Nobody/Anonymous

    I just installed Dev C++ version 4.9.8.0 and downloaded the glut files from http://mywebpage.netscape.com/PtrPck/glut.htm

    I followed the instructions and copied the *.a files to the lib directorie, the *.dll (glut32.dll) to the bin directory and the headers to include/GL

    I copied the small program in the FAQ and tried to compile it. This is my compile log

    Compiler: Default compiler
    Executing  g++.exe...
    g++.exe "H:\Ravager\programas\Dev-Cpp-C++\los mios\Untitled1.cpp" -o "H:\Ravager\programas\Dev-Cpp-C++\los mios\Untitled1.exe"    -I"H:\Ravager\programas\Dev-Cpp-C++\include\c++"  -I"H:\Ravager\programas\Dev-Cpp-C++\include\c++\mingw32"  -I"H:\Ravager\programas\Dev-Cpp-C++\include\c++\backward"  -I"H:\Ravager\programas\Dev-Cpp-C++\include"   -L"H:\Ravager\programas\Dev-Cpp-C++\lib"
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x15):Untitled1.cpp: undefined reference to `__glutInitWithExit@12'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x32):Untitled1.cpp: undefined reference to `__glutCreateWindowWithExit@8'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x50):Untitled1.cpp: undefined reference to `__glutCreateMenuWithExit@8'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x6b):Untitled1.cpp: undefined reference to `glClear@4'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x85):Untitled1.cpp: undefined reference to `glColor3f@12'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x92):Untitled1.cpp: undefined reference to `glBegin@4'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0xa9):Untitled1.cpp: undefined reference to `glVertex3f@12'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0xc0):Untitled1.cpp: undefined reference to `glVertex3f@12'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0xd7):Untitled1.cpp: undefined reference to `glVertex3f@12'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0xee):Untitled1.cpp: undefined reference to `glVertex3f@12'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0xf6):Untitled1.cpp: undefined reference to `glEnd@0'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0xfb):Untitled1.cpp: undefined reference to `glFlush@0'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x111):Untitled1.cpp: undefined reference to `glClearColor@16'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x11e):Untitled1.cpp: undefined reference to `glMatrixMode@4'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x126):Untitled1.cpp: undefined reference to `glLoadIdentity@0'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x14f):Untitled1.cpp: undefined reference to `glOrtho@48'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x192):Untitled1.cpp: undefined reference to `glutInitDisplayMode@4'

    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x1a7):Untitled1.cpp: undefined reference to `glutInitWindowSize@8'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x1b6):Untitled1.cpp: undefined reference to `glutInitWindowPosition@8'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x1db):Untitled1.cpp: undefined reference to `glutDisplayFunc@4'
    H:\DOCUME~1\Doudou\CONFIG~1\Temp/cciEbaaa.o(.text+0x1e3):Untitled1.cpp: undefined reference to `glutMainLoop@0'

    Execution terminated

    I've been reading again and again the FAQ FORUM but I can't find what I did wrong

     
    • Wayne Keen

      Wayne Keen - 2004-05-03

      Look at your log again.  The Glut libraries have NOT been linked.  In the getting started section I told you exactly how to do that.

      Here is the quote from the section:

      "Compiling this as a simple file, I went to Tools:Compiler Options:Compiler:Add these Commands To The Linker Command Line

      -lglut32 -lopengl32"

      Note that in my log from the example, the link commands show up:

      Compiler: Default compiler
      Executing g++.exe...
      g++.exe "C:\mycstuff\glutter.cpp" -o "C:\mycstuff\glutter.exe" -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -lglut32 -lopengl32
      Execution terminated
      Compilation successful

      That is the value of (a) Showing the compile log, which you did, bravo and (b) Looking at it yourself.  If you think you are linking something, always check your log to see if the link command is actually executed.

      Wayne

       
    • Nobody/Anonymous

      It works!!! I just had to the command -lglut32 -lopengl32 to the command file, not only the linker command file.

      Now I am trying to link my code, but some linkers command are missing and I don't know how to find them. Here is my main.c code and my compile log:

      #include <GL/glut.h>
      #include <GL/gl.h>

      #include "droite.h"
      #include "triangle.h"

      // affiche un pixel de la couleur actuellement definie
      void draw_pixel(int x, int y)
      {
          glBegin(GL_QUADS);
              glVertex2i(x,   y);
              glVertex2i(x +1, y);
              glVertex2i(x +1, y +1);
              glVertex2i(x,    y +1);
          glEnd();
      }

      void display(void)
      {
      /*  clear all pixels  */
          glClear(GL_COLOR_BUFFER_BIT);

          glColor3f(1.0, 1.0, 0.0);

      #if 0
          main_droite();

      #else
          main_triangle();
      #endif

      /*  don't wait! 
      *  start processing buffered OpenGL routines
      */
          glFlush ();
      }

      void init (void)
      {
      /*  select clearing (background) color       */
          glClearColor (0.0, 0.0, 0.0, 0.0);

      /*  initialize viewing values  */
          glMatrixMode(GL_PROJECTION);
          glLoadIdentity();
          glOrtho(0.0, 40.0, 0.0, 40.0, -1.0, 1.0);
      }

      /*
      *  Declare initial window size, position, and display mode
      *  (single buffer and RGBA).  Open window with "hello"
      *  in its title bar.  Call initialization routines.
      *  Register callback function to display graphics.
      *  Enter main loop and process events.
      */
      int main(int argc, char** argv)
      {
          glutInit(&argc, argv);
          glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
          glutInitWindowSize (400, 400);
          glutInitWindowPosition (100, 100);
          glutCreateWindow ("hello");
          init();
          glutDisplayFunc(display);
          glutMainLoop();
          return 0;
      }

      Compiler: Default compiler
      Building Makefile: "H:\Ravager\programas\Dev-Cpp-C++\los mios\Makefile.win"
      Executing  make...
      make.exe -f "H:\Ravager\programas\Dev-Cpp-C++\los mios\Makefile.win" all
      gcc.exe droite.o main.o minigl.o triangle.o  -o "arboles.exe" -L"H:/Ravager/programas/Dev-Cpp-C++/lib"

      minigl.o(.text+0x0):minigl.c: multiple definition of `display'

      main.o(.text+0x72):main.c: first defined here
      minigl.o(.text+0xa6):minigl.c: multiple definition of `init'
      main.o(.text+0xb2):main.c: first defined here
      minigl.o(.text+0x100):minigl.c: multiple definition of `main'
      main.o(.text+0x11a):main.c: first defined here
      droite.o(.text+0x37a):droite.c: undefined reference to `_imp__glColor3f'
      droite.o(.text+0x3a0):droite.c: undefined reference to `_imp__glColor3f'
      droite.o(.text+0x3c6):droite.c: undefined reference to `_imp__glColor3f'
      droite.o(.text+0x3ef):droite.c: undefined reference to `_imp__glColor3f'
      main.o(.text+0xc):main.c: undefined reference to `_imp__glBegin'
      main.o(.text+0x1f):main.c: undefined reference to `_imp__glVertex2i'
      main.o(.text+0x34):main.c: undefined reference to `_imp__glVertex2i'
      main.o(.text+0x4b):main.c: undefined reference to `_imp__glVertex2i'
      main.o(.text+0x60):main.c: undefined reference to `_imp__glVertex2i'
      main.o(.text+0x6a):main.c: undefined reference to `_imp__glEnd'
      main.o(.text+0x81):main.c: undefined reference to `_imp__glClear'
      main.o(.text+0x9a):main.c: undefined reference to `_imp__glColor3f'
      main.o(.text+0xa9):main.c: undefined reference to `_imp__glFlush'
      main.o(.text+0xc1):main.c: undefined reference to `_imp__glClearColor'
      main.o(.text+0xd3):main.c: undefined reference to `_imp__glMatrixMode'
      main.o(.text+0xdd):main.c: undefined reference to `_imp__glLoadIdentity'
      main.o(.text+0x108):main.c: undefined reference to `_imp__glOrtho'
      main.o(.text+0x143):main.c: undefined reference to `glutInit'
      main.o(.text+0x150):main.c: undefined reference to `glutInitDisplayMode'

      main.o(.text+0x165):main.c: undefined reference to `glutInitWindowSize'
      main.o(.text+0x174):main.c: undefined reference to `glutInitWindowPosition'
      main.o(.text+0x184):main.c: undefined reference to `glutCreateWindow'
      main.o(.text+0x199):main.c: undefined reference to `glutDisplayFunc'
      main.o(.text+0x1a1):main.c: undefined reference to `glutMainLoop'
      minigl.o(.text+0xf):minigl.c: undefined reference to `glClear@4'
      minigl.o(.text+0x29):minigl.c: undefined reference to `glColor3f@12'
      minigl.o(.text+0x36):minigl.c: undefined reference to `glBegin@4'
      minigl.o(.text+0x4d):minigl.c: undefined reference to `glVertex3f@12'
      minigl.o(.text+0x64):minigl.c: undefined reference to `glVertex3f@12'
      minigl.o(.text+0x7b):minigl.c: undefined reference to `glVertex3f@12'
      minigl.o(.text+0x92):minigl.c: undefined reference to `glVertex3f@12'
      minigl.o(.text+0x9a):minigl.c: undefined reference to `glEnd@0'
      minigl.o(.text+0x9f):minigl.c: undefined reference to `glFlush@0'
      minigl.o(.text+0xb5):minigl.c: undefined reference to `glClearColor@16'
      minigl.o(.text+0xc2):minigl.c: undefined reference to `glMatrixMode@4'
      minigl.o(.text+0xca):minigl.c: undefined reference to `glLoadIdentity@0'
      minigl.o(.text+0xf3):minigl.c: undefined reference to `glOrtho@48'

      minigl.o(.text+0x129):minigl.c: undefined reference to `glutInit@8'
      minigl.o(.text+0x136):minigl.c: undefined reference to `glutInitDisplayMode@4'
      minigl.o(.text+0x14b):minigl.c: undefined reference to `glutInitWindowSize@8'
      minigl.o(.text+0x15a):minigl.c: undefined reference to `glutInitWindowPosition@8'
      minigl.o(.text+0x16a):minigl.c: undefined reference to `glutCreateWindow@4'
      minigl.o(.text+0x17f):minigl.c: undefined reference to `glutDisplayFunc@4'

      minigl.o(.text+0x187):minigl.c: undefined reference to `glutMainLoop@0'
      triangle.o(.text+0x817):triangle.c: undefined reference to `_imp__glColor3f'
      triangle.o(.text+0x845):triangle.c: undefined reference to `_imp__glColor3f'
      make.exe: *** [arboles.exe] Error 1

      Execution terminated

       
    • Nobody/Anonymous

      No need to answer for the linking problem, I found what was wrong!! I forgot it was a project. But I still have this compiling problem taht I don't understand

      Compiler: Default compiler
      Building Makefile: "H:\Ravager\programas\Dev-Cpp-C++\los mios\Makefile.win"
      Executing  make...
      make.exe -f "H:\Ravager\programas\Dev-Cpp-C++\los mios\Makefile.win" all
      gcc.exe droite.o main.o minigl.o triangle.o  -o "arboles.exe" -L"H:/Ravager/programas/Dev-Cpp-C++/lib" -lglut32 -lopengl32

      minigl.o(.text+0x0):minigl.c: multiple definition of `display'

      main.o(.text+0xce):main.c: first defined here
      minigl.o(.text+0xa6):minigl.c: multiple definition of `init'
      main.o(.text+0x10e):main.c: first defined here
      minigl.o(.text+0x100):minigl.c: multiple definition of `main'
      main.o(.text+0x170):main.c: first defined here

      make.exe: *** [arboles.exe] Error 1

      Execution terminated

       
    • Anonymous

      Anonymous - 2004-05-03

      That is an odd compile log, your project seems to consist of all .o files and no source files. This is consequently a linker error not a compiler error - the compiler simply passes .o files to the linker.

      As the messages state, display, init, and main are defined in more than one object file. You maynot need both main.o and minigl.o

      Clifford

       
    • aditsu

      aditsu - 2004-05-05

      that's the kind of compile log that you get when all the files compile fine and there are linker errors, and you compile it the second time, without rebuilding all

      Adrian

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.