Question about OpenGL/Linux

This is a discussion on Question about OpenGL/Linux within the Linux Programming forums, part of the Platform Specific Boards category; I want to start scripting some simple OpenGL programs in SuSE Linux 10.1, I tried some tutorials from nehe.gamedev.net, I ...

  1. #1
    C / C++
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    312

    Question about OpenGL/Linux

    I want to start scripting some simple OpenGL programs in SuSE Linux 10.1, I tried some tutorials from nehe.gamedev.net, I downloaded the Linux version of the tutorial and I installed the GLUT library (At least, I think it's installed now), but it still doesn't recognize all the GLUT functions. I am compiling with $ gcc lesson1.c Should I download another OpenGL library, use another program, or just give it up and only use OpenGL on Windows?
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  2. #2
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Scripting is outside the scope of this forum... unless you meant coding, or programming or somesuch like that. Does the code you are trying to compile, compile on windows? Remeber that NeHe tutorials use some of the old functions that need to be replaced, since one of the headers is no longer with. glaux I think it was...

  3. #3
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Quote Originally Posted by Ideswa
    I want to start scripting some simple OpenGL programs in SuSE Linux 10.1, I tried some tutorials from nehe.gamedev.net, I downloaded the Linux version of the tutorial and I installed the GLUT library (At least, I think it's installed now), but it still doesn't recognize all the GLUT functions. I am compiling with $ gcc lesson1.c Should I download another OpenGL library, use another program, or just give it up and only use OpenGL on Windows?
    It might be helpful to see what GL headers you included, as well as the command you used to invoke gcc.

  4. #4
    C / C++
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    312
    I didn't change anything on this script (Linux version): http://nehe.gamedev.net/data/lessons....asp?lesson=01
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Please post the exact error messages you are getting and, as kermit has already requested, details of how you are invoking gcc.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  6. #6
    C / C++
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    312
    undefined reference to `glClearColor'
    undefined reference to `glClearDepth'
    undefined reference to `glDepthFunc'
    undefined reference to `glEnable'
    undefined reference to `glShadeModel'
    undefined reference to `glMatrixMode'
    undefined reference to `glLoadIdentity'
    undefined reference to `gluPerspective'
    undefined reference to `glMatrixMode'
    /tmp/ccu2nMyV.o: In function `ReSizeGLScene':
    undefined reference to `glViewport'
    undefined reference to `glMatrixMode'
    undefined reference to `glLoadIdentity'
    undefined reference to `gluPerspective'
    undefined reference to `glMatrixMode'
    /tmp/ccu2nMyV.o: In function `DrawGLScene':
    undefined reference to `glClear'
    undefined reference to `glLoadIdentity'
    undefined reference to `glutSwapBuffers'
    /tmp/ccu2nMyV.o: In function `keyPressed':
    undefined reference to `glutDestroyWindow'
    /tmp/ccu2nMyV.o: In function `main':
    undefined reference to `glutInit'
    undefined reference to `glutInitDisplayMode'
    undefined reference to `glutInitWindowSize'
    undefined reference to `glutInitWindowPosition'
    undefined reference to `glutCreateWindow'
    undefined reference to `glutDisplayFunc'
    undefined reference to `glutFullScreen'
    undefined reference to `glutIdleFunc'
    undefined reference to `glutReshapeFunc'
    undefined reference to `glutKeyboardFunc'
    undefined reference to `glutMainLoop'
    This is what I get. As you can see, I invoke like this: gcc lesson.c
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  7. #7
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Just as I thought - you need to give gcc a little more info than that. Its been a while since I have built any GL stuff on my machine, but IIRC, it depends a little on your setup exactly the commands you will need to use. Try having a look at this and this. Should give you an idea of what to look for anyway..

  8. #8
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640

  9. #9
    C / C++
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    312
    Thanks for the replies, the libraries were ok, but I needed those arguments to compile. It works now! Yay!
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  10. #10
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Please stop calling it a script unless it is written in something like Bash, Perl, Python or some other scripting language... I eluded to that in my first message. C/C++ is 'source code'.

  11. #11
    C / C++
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    312
    @wraithan: sorry :P I started with PHP, and that's a scripting language, isn't it? So I'm used to say 'scripting'.

    I have a few questions about openGL (I did some tutorials at nehe.gamedev.net)
    1. If I use glutIdleFunc(&DrawGLScene); in my code (It's necessary for rotating a cube), The program closes a few seconds after I click the close button or press the Escape button. Why?

    2. And I get this warning when I execute:
    freeglut (./a.out): Unable to create direct context rendering for window 'Jeff Molofee's GL Code Tutorial ... NeHe '99' This may hurt performance.
    How can I solve that?

    3. If I don't focus on the program window, the animation is about 5 times faster. Is that a SuSE linux bug?
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  12. #12
    Registered User
    Join Date
    Sep 2006
    Posts
    1

    Question

    Quote Originally Posted by Ideswa
    Thanks for the replies, the libraries were ok, but I needed those arguments to compile. It works now! Yay!
    It seems that i am facing the exact same problem as you. Can you please tell me what arguments did you use?

    I was able to make my program run once by using the command
    gcc -o myProg myProg.c -lglut -lGL -lGLU -lX11 -lXmu -lXi -lm
    but why cant i run it throug my editor directly (i m using Anjuta)? What editor are you using?

    Also i guess i can make a makefile as the links above show but then will i have to make a different makefile for each program i make and run it each time i run the program??

    Someone please suggest a workaround. And also can someone tell me what these arguments mean exactly?

  13. #13
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    First of all, replying to a post which has been inactive for more than a coupld of weeks is generally frowned upon.

    From the Forum Guidelines (which you should have already read before posting:

    5. Don't bump threads. (Bumping: posting messages on threads to move them up the list or to post on a thread that has been inactive for two weeks or longer).

    Anyway, as to a couple of your questions...

    >but then will i have to make a different makefile for each program i make and run it each time i run the program??

    Make is about automating your project build (actually make can do a whole lot more that just look after a project build). You will definitely need a makefile or each separate program, for, presumably, each separate program will have different names (otherwise they would not be separate programs now would they?). Build requirements also change as well. One program might have 8 source files, and another might have 80. Each program will have a makefile which reflects these differences. Sure, its a bit of an initial hassle typing out a makefile for each project, but in the long run (especially as your project gets larger) it gets a whole lot easier to just edit the makefile from time to time as you need to change it, and then just type in 'make' (or click 'build' in your ide) then to type in all of the separate file names and all of the flags that you need every single time.

    >And also can someone tell me what these arguments mean exactly?

    I am assuming you mean these?:

    Code:
    gcc -o myProg myProg.c  -lglut -lGL -lGLU -lX11 -lXmu -lXi -lm
    -l is a switch for the linker - it says link whatever follows. So in this case:

    1. -lglut: link the glut library
    2. -lGL: link the GL library
    3. lGLU: link the GLU library
    4. etc etc...
    5. -lm: link the math library

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21