Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Error!!! Undefined reference

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    14

    Error!!! Undefined reference

    when i compile the program, i get the error: "undefined reference to glutSolidSphere."

    i have included the include file #include<GL/glut.h> and #include<GL/glu.h>. I have both these header files and they have declared glutSolidSphere in them.

    Also it looks like glu32.lib is not in my system.Could that be the problem?

    Would appreciate info as to how to solve this problem. As of now, i'm not able to draw any cylinder or sphere, and ultimately, i need to draw submarines and ships(so cylinders seem indispensable). Thanx!

  2. #2
    Senior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Nanjing,China
    Posts
    116

    Re: Error!!! Undefined reference

    glutSolidSphere is declared in glut.h
    and gluSphere is declared in glu.h
    I don't think you can get the glutSolidSphere in glu.h file.

    Just assume that you use win os and vc 6, otherwise i am not in a position to provide opinion.

    Use the following command to look up to the lib
    # pragma comment (lib, "glut32.lib")
    # pragma comment (lib, "glu32.lib")


    Don't forget the copy the lib into the lib directory in vc6 and dll to the System 32 directory.


    [This message has been edited by RunningRabbit (edited 07-12-2003).]

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: Error!!! Undefined reference

    What operating system are you using?
    What compiler are you using?

    To compile a glut based program, the opengl library, glu library, and glut library.


    Originally posted by just_started:
    when i compile the program, i get the error: "undefined reference to glutSolidSphere."

    i have included the include file #include<GL/glut.h> and #include<GL/glu.h>. I have both these header files and they have declared glutSolidSphere in them.

    Also it looks like glu32.lib is not in my system.Could that be the problem?

    Would appreciate info as to how to solve this problem. As of now, i'm not able to draw any cylinder or sphere, and ultimately, i need to draw submarines and ships(so cylinders seem indispensable). Thanx!



    [This message has been edited by nexusone (edited 07-12-2003).]

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    14

    Re: Error!!! Undefined reference

    am using Linux platform (Red Hat 9.0). i had installed all the required libraries from the installation CD itself, nothing additional. The glut lib was included at installation time itself. I use Qt to code the pgm. could anyone think of any pointers?

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: Error!!! Undefined reference

    Try this:

    g++ -lglut -lGL -lGLU myfile.cpp -o myprog

    If you get other undefined references, you'll need to find which library those are in, and so on and so on, until you get all the necessary libraries included for the linker.
    Deiussum
    Software Engineer and OpenGL enthusiast

  6. #6
    Senior Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    763

    Re: Error!!! Undefined reference

    beware -- there are rumoured issues with glut and redhat 9. You may need to downgrade your glut libraries to a slightly older version if you continue getting weird linking errors. (That linking error isn't one of the weird ones, incidentially.)

    cheers,
    John

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: Error!!! Undefined reference

    I am currently programming openGL under linux on RedHat 9.0, note that the GLUT version shipped with 9.0 has a problem.
    The solution is posted in the openGL linux forum, which is to download the glut library from 8.0 and install it over the 9.0 version of the library.

    I have a few glut examples on my website www.angelfire.com/linux/nexusone/

    Also QT or SDL library maybe another good choice over using glut library.

    I use the QT IDE for compiling my glut examples, but also you can use the QT library to open a windows for openGL. The QT website has some examples of programming under their X-windows (KDE) library interface OpenGL.

    I need to post on my website an example of setting up QT to compile an openGL program.


    Originally posted by just_started:
    am using Linux platform (Red Hat 9.0). i had installed all the required libraries from the installation CD itself, nothing additional. The glut lib was included at installation time itself. I use Qt to code the pgm. could anyone think of any pointers?

  8. #8
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    14

    Re: Error!!! Undefined reference

    Thanx! that's a confirmation of what i was begining to suspect. i had a feeling there was something wrong with the GLUT itself. Guess i've to go looking 4 the older version now

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: Error!!! Undefined reference

    You do still need to add the -l stuff, though. The linker doesn't try and look through every single library file you have. For any of the non-standard libraries, you NEED to tell the linker to check them.

    Your error in itself doesn't mean you are having the Red Hat 9.0/Glut problem. Even after you get the version of glut for Red Hat 8.0, you'll still have that problem if you don't add the -lglut -lGL -lGLU parameters.
    Deiussum
    Software Engineer and OpenGL enthusiast

  10. #10
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    14

    Re: Error!!! Undefined reference

    hi all

    i've been struggling without GLUT 4 some time now. sorry i didn't quite get that
    -lglut -lGL -lGLU myfile.cpp -o myprog

    i am working with qt, and all i do for compiling and linking is:
    >qmake -project
    >qmake
    >make
    i've just started working with Linux & so am quite unfamiliar with the works.

    i've downloaded the glut_data-3.6.tar and glut-3.6.tar files, but i'm at a loss to understand what to do next.

    the readme file says to replace glut.cf file with the latest one, but there already is no such file in my system.there's no GLUT_HOME either. so where do i put this one? can i just make a new directory, as well as a new lib directory within it?

    is there some way of getting an GLUT installation package; one that will do all the installation?

    Thanx 4 all ur help

Page 1 of 2 12 LastLast

Similar Threads

  1. Undefined reference error
    By SagoO in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-15-2010, 09:17 AM
  2. Undefined Reference Error Message
    By tafazolisina in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-15-2009, 02:41 AM
  3. {Linker error} undefined reference to ...
    By jauhoy in forum OpenGL: Windows
    Replies: 3
    Last Post: 03-25-2009, 06:43 PM
  4. [Linker error] Undefined reference to 'gl***'
    By Anklebiter in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 01-19-2005, 09:47 AM
  5. [Linker error] undefined reference to ...
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-29-2002, 01:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean