opengl - Cannot get open GL to run on Dev ++ -


i trying run opengl on dev c++. , cannot code run. i've tried on site:

http://www.prinmath.com/csci5229/misc/devc_opengl_for_windows.pdf

my operating system windows 7-64 bit. use different ide if school insists use dev c++.

here code trying run:

#include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h>       void init() {     glclearcolor (1.0, 1.0, 1.0, 0.0);       glmatrixmode (gl_projection);            gluortho2d (0.0, 200.0, 0.0, 200.0);  }  void linesegment() {     glclear (gl_color_buffer_bit);  // clear display window. color buffer      glcolor3f (0.0, 0.0, 0.0);      int p1 [ ] = {40,80}; int p2 [ ] = {160, 80}; int p3 [ ] = {100, 40}; int p4 [ ] = {100, 160}; int p5 [ ] = {0, 80}; int p6 [ ] = {200, 200}; int p7 [ ] = {100, 0}; int p8 [ ] = {100,200 }; int p9 [ ] = {30, 30}; int p10 [ ] = {0, 0};  glbegin(gl_line_loop); glvertex2iv(p1); glvertex2iv(p2); glvertex2iv(p3); glvertex2iv(p4);      glflush ( );      }  int main(int argc, char *argv[]) {     glutinit (&argc, argv);                         // initialize glut.     glutinitdisplaymode (glut_single | glut_rgb);   // set display mode, single buffering.     glutinitwindowposition (50, 100);   // set top-left display-window position.     glutinitwindowsize (400, 300);      // set display-window width , height.     glutcreatewindow ("an example opengl program"); // create display window.      init( );                            // execute initialization procedure.     glutdisplayfunc (linesegment);       // send graphics display window.     glutmainloop ( );                    // display , wait.      //return exit_success();     return 0;    } 

and here compile log says when try compile:

gcc.exe -d__debug__ -c testlab.c -o testlab.o -i"c:/dev-cpp/include"    -pg -g3  windres.exe -i testproject_private.rc --input-format=rc -o testproject_private.res -o coff   gcc.exe -d__debug__ testlab.o testproject_private.res -o "testproject.exe" -l"c:/dev-cpp/lib" -mwindows -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32  -lgmon -pg  -g3   /mingw/lib/gcc/mingw32/../../../mingw32/lib/crt2.o(.text+0x18a)c:\dev-cpp\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: dwarf error: found dwarf version '4', reader handles version 2 information. :crt1.c: undefined reference `__dyn_tls_init_callback' /mingw/lib/gcc/mingw32/../../../mingw32/lib/crt2.o(.text+0x1be):crt1.c: undefined reference `__cpu_features_init' /mingw/lib/gcc/mingw32/../../../mingw32/lib/crt2.o(.text+0x1f1):crt1.c: undefined reference `__chkstk_ms' /mingw/lib/gcc/mingw32/../../../mingw32/lib/crt2.o(.text+0x376):crt1.c: undefined reference `__mingw_glob' /mingw/lib/gcc/mingw32/../../../mingw32/lib/crt2.o(.text+0x47d):crt1.c: undefined reference `__mingw_glob' testlab.o(.text+0x26): in function `glutinit_atexit_hack': c:/dev-cpp/include/gl/glut.h:455: undefined reference `_imp____glutinitwithexit@12'  testlab.o(.text+0x52): in function `glutcreatewindow_atexit_hack': c:/dev-cpp/include/gl/glut.h:472: undefined reference `_imp____glutcreatewindowwithexit@8' testlab.o(.text+0x7e): in function `glutcreatemenu_atexit_hack': c:/dev-cpp/include/gl/glut.h:518: undefined reference `_imp____glutcreatemenuwithexit@8' testlab.o(.text+0x26a): in function `main': c:/users/../testlab.c:43: undefined reference `_imp__glutinitdisplaymode@4' testlab.o(.text+0x283):c:/users/../testlab.c:44: undefined reference `_imp__glutinitwindowposition@8' testlab.o(.text+0x29c):c:/users/../testlab.c:45: undefined reference `_imp__glutinitwindowsize@8' testlab.o(.text+0x2c1):c:/users/../testlab.c:49: undefined reference `_imp__glutdisplayfunc@4' testlab.o(.text+0x2cb):c:/users/../testlab.c:50: undefined reference `_imp__glutmainloop@0' collect2: ld returned 1 exit status  make.exe: *** [testproject.exe] error 1  execution terminated 

looks you're linking wrong version of c-runtime (crt).

  • if have multiple versions of mingw installed, show dev-c++ find right includes , libs (check path environment variable, mingw_home environment variable , dev-c++ compiler options). must use crt ships compiler.
  • try #include <windows.h> before other includes. can fix dllimports stuff
  • try add -m32 flag compiler command line (it emit code x86_32, in case if compiling 64-bit compiler)
  • ask teacher how fix (it's (her) job, , it's (s)he choose use 10 years old stuff)

note, latest version of dev-c++ released 22.02.2005. includes gcc 3.4.2 released september 6, 2004. must ask teachers why insist on using 9 years old ide 10 years old compiler. can find maintained version of dev-c++ here (it picked developer), , latest mingw compiler here.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -