View Full Version : Linux - compilation problems
Previous link
http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/009680.html
Hi,
I installed linux 7.2 and when i compiled my code it gives loads of errors. All of them says "undefined reference to <function name>"
for ex.
/tmp/cc10oCCFz.o(.text+0x132a):undefined reference to 'glRotatef'
all the errors are similar to the above(only variation is (.text+0xnumber))
The error is for all opengl related functions,sine,cos and tan functions.
I have included all header files
what is the problem?
thanks in advance
simon
killercow
08-30-2002, 06:43 AM
sounds liks you're not linking to the opengl libraries.
try adding
-lglut32 -lopengl32
to your compile command.
should be somethign like this:
g++ lesson260802.cpp -o test -lglut32 -lglu32 -lopengl32 -Wall
coredump
08-30-2002, 07:42 AM
...sine,cos and tan functions.
maybe you also need -lm
Latrans
08-30-2002, 09:02 AM
For linux, I believe it would be -lglut -lGL -lGLU.
Note: No 32's in there, and GL and GLU are all caps. Case does matter in Linux.
Hi,
I typed the following command
g++ filename.C -o test -lglu32 -lglut32 -lopengl32 -Wall
message is:
/usr/bin/ld: cannot find -lglu32
collect2: ld returned 1 exit status
I tried with -lm and also -lGL & -lGLU, -lGLU32 etc. but the result is same type of error.
Do i have to set path variables or somthing like that(like windows) after linux installation?
I'm sure that gl.h, glu.h glut.h files are in /usr/include/GL
I don't know what i'm missing.
Help me guys. Hope not annoying you people.
Thanks
simon
rixed
08-31-2002, 01:27 AM
The problem, then, maybe that you have NO the openGL library ?
what video card do you use ?
when you say -lGL, it means "link that with the file libGL.so", the file beeing looked for in every path listed in /etc/ld.so.conf.
So, do you have that file ?
I suppose at least that the -lm get rid of the complaints about sin, cos, etc... ?
Hi
I have the file libGL.so in \usr\lib. But I don't know whether the path is listed in \etc\ld.so.conf. How to check it?
By the way my video card is ATI Rage Pro AGP(according to windows). But Linux 7.2 detected as ATI Mach-64.
I didn't installed any special opengl files. But in windows i downloaded opengl header files, dll files etc. Do I have to do something like that for linux?
I checked in lib directory and there is a seperate directory for GL.
I don't know whether i have to install special display drivers for opengl in linux.
Now I am totally confused.
Simon
Originally posted by rixed:
The problem, then, maybe that you have NO the openGL library ?
what video card do you use ?
when you say -lGL, it means "link that with the file libGL.so", the file beeing looked for in every path listed in /etc/ld.so.conf.
So, do you have that file ?
I suppose at least that the -lm get rid of the complaints about sin, cos, etc... ?
Hi guys
I tried a simple program in linux
#include <stdio.h>
main()
{
printf(" \n This is ok. no problemo");
}
When I typed a.out, it says
bash: a.out: command not found
I tried in different shells(csh,sh). result is same.
a.out is created in the same working directory
I dont know what's the mistake.
Simon
Latrans
09-05-2002, 06:57 AM
Try:
./a.out
BTW, you can use -o someMoreRationalName
To name the binary something other than a.out.
atlast ./a.out worked(thanks Latrans). But I still can't execute my opengl code sucessfully.
By the way, What's the difference between a.out and ./a.out?
To my knowledge(correct me if i'm wrong), a.out means transferring the machine code(or assembly code) to standard output device.
Many Thanks
simon
Originally posted by Latrans:
Try:
./a.out
BTW, you can use -o someMoreRationalName
To name the binary something other than a.out.
Gavin
09-10-2002, 04:14 AM
nah a.out is just the default output name from the compiler.
gcc myprog.cpp -o myprog
or whatever.
Use a makefile, it will simplify your life alot. You can add all your paths in the makefile rather than set your paths in the conf file if you so wish. Ask someone for a simple Linux one and hack it as you need.
Deiussum
09-10-2002, 05:07 AM
The reason you needed ./a.out rather than a.out is because by default many Linux implementations do not search the current directory. Using ./ in front of it explicitly stated that a.out was in the current directory, and thus it was able to find the binary to execute.
Hi Guys,
Finally I managed to compile a simple opengl code sucessfully(i think) linking all the files.
command : gcc <filename.c> -lGL -lGLU -lglut
But it gives the following error.
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libGL.so: Undefined reference to 'pow'
collect2: ld returned 1 exit status
I have only 2 subdirectories after 2.96. But the error shows 3 subdirectories.
I have only one libGL.so and that's in /usr/lib
can you point out my mistake?
Thanks a million
simon
Hi guys,
Finally i got it. Haven't specified -lm.
But I haven't used any math functions. Using glVertex i drew a square. that's all. no calculation, nothing.
I couldn't understand why i should -lm. I'm wondering whether opengl uses math functions internally?
Any idea guys?
Anyway finally i got a clear picture of what and how different files are linked during compilation.
Many many many thanks guys
simon
marcus256
09-11-2002, 01:19 AM
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libGL.so: Undefined reference to 'pow'
collect2: ld returned 1 exit status
This indicates that libGL.so (in other words, the GL library) uses the 'pow' math function.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.