PDA

View Full Version : Error!!! Undefined reference



just_started
07-12-2003, 12:19 AM
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!

Sourpotato
07-12-2003, 12:34 AM
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).]

nexusone
07-12-2003, 06:32 AM
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).]

just_started
07-14-2003, 06:47 PM
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?

Deiussum
07-15-2003, 05:37 AM
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.

john
07-15-2003, 06:04 AM
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

nexusone
07-15-2003, 06:07 AM
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/ (http://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?

just_started
07-16-2003, 07:13 AM
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 http://www.opengl.org/discussion_boards/ubb/rolleyes.gif

Deiussum
07-16-2003, 10:11 AM
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.

just_started
07-30-2003, 08:48 AM
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

Clayton
07-30-2003, 09:51 AM
If you're using QT, in your .pro file that you use to compile the makefile, try adding "opengl" where your project file says something like CONFIG += qt warn_on_release so it says CONFIG += qt warn_on_release opengl. If you don't have the config line at all (you should) just add it without the qt or warn_on_release.

By the way, if you're compiling with QT, there are very good provisions for using openGl. http://doc.trolltech.com/3.2/index.html is the QT documentation (for the 3.2 beta, if you need the other ones just go back to doc.trolltech.com) http://doc.trolltech.com/3.2/qglwidget.html is the documentation for the qglwidget, which is a much more functional base OpenGL class for you to derive your openGL from. There are examples on that site of how it all works. That way you don't have to worry about glut either.
You might wish to try that.

[This message has been edited by Clayton (edited 07-30-2003).]

nexusone
07-30-2003, 11:34 AM
First if you are a newbie don't try to compile the library from the source files, just download the GLUT RPM files from the Redhat website and install them.

Maybe also before trying to program in linux learn a little more about how to use some of the linux functions. Like installing RPM files, which under Linux work similar to the windows installer program.


Originally posted by just_started:
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

just_started
07-31-2003, 07:20 AM
but i've already tried the rpm installation. it says that "this file is already installed on this machine". i'm actually beginning to wonder if the problem is with qt compilation.

and yes, i'm already using QGLWidget, but i need to draw cylinders and stuff, so at least glu library is needed, preferably glut, too.

right now, i get glu lib by editing the make file . but i'd like to do it in a more straight forward manner, if possible.

i haven't yet tried out that .pro file editing. will get back after that.

thanx 4 the help

[This message has been edited by just_started (edited 07-31-2003).]

nexusone
07-31-2003, 08:38 AM
You will have to force install the older glut, you have to do it from a terminal window.

I think the it is:
rpm -force glutXXXX.XXXX.rpm

Also make sure you install both the develope and run time library. Will not work without both installed.

the library's in linux look like this: libglut.so, libGL.so (openGl32 on windows), libGLU.so

I use Kdevelope IDE, nice windows type interface does all the make files stuff automatically. (it is shipped with RH) just add the library's in the linker settings dialog window.
I am not on the linux machine right now, but I think it is under project - settings -linker.



Originally posted by just_started:
but i've already tried the rpm installation. it says that "this file is already installed on this machine". i'm actually beginning to wonder if the problem is with qt compilation.

and yes, i'm already using QGLWidget, but i need to draw cylinders and stuff, so at least glu library is needed, preferably glut, too.

right now, i get glu lib by editing the make file . but i'd like to do it in a more straight forward manner, if possible.

i haven't yet tried out that .pro file editing. will get back after that.

thanx 4 the help

[This message has been edited by just_started (edited 07-31-2003).]

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

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