LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-02-2007, 02:18 PM   #1
eerpini
Member
 
Registered: Mar 2007
Posts: 36

Rep: Reputation: 15
Help needed regarding opengl


i have openGL installed on my FC6 system , i have the header files installed in the standard /usr/include/GL directory , but when i run programs , the gcc compiler does not reecognise the functions which are defined in these header files



the header files i have included are :
#include<GL/glut.h>
#include<GL/gl.h>
#include<GL/glx.h>
#include<GL/glu.h>

i have also tried setting the LD_LIBRARY_PATH variable but of no use , the problem still persists after doin tat !
please help , .
thanks in advance !
 
Old 06-02-2007, 02:33 PM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
You should at least quote all error messages from gcc that make you think it doesn't recognize your libraries.
 
Old 06-02-2007, 02:42 PM   #3
hondo
Member
 
Registered: Jul 2005
Location: norway
Posts: 198

Rep: Reputation: 33
If you manally installed the header files into this location and if this location is standard location for libraries, then you should execute the "ldconfig" command and it should work.
 
Old 06-02-2007, 11:26 PM   #4
eerpini
Member
 
Registered: Mar 2007
Posts: 36

Original Poster
Rep: Reputation: 15
these were the errors shown ,
/tmp/ccOpyBLn.o: In function `Transform':
sam.c.text+0x49): undefined reference to `glViewport'
sam.c.text+0x55): undefined reference to `glMatrixMode'
sam.c.text+0x5a): undefined reference to `glLoadIdentity'
sam.c.text+0x86): undefined reference to `gluPerspective'
sam.c.text+0x92): undefined reference to `glMatrixMode'


there is no use even when i run the ldconfig command , can u suggest anything else?
 
Old 06-02-2007, 11:27 PM   #5
eerpini
Member
 
Registered: Mar 2007
Posts: 36

Original Poster
Rep: Reputation: 15
this is the other set of errors , i did not postthem above due to lack of space !

/tmp/ccOpyBLn.o: In function `main':
sam.c.text+0x118): undefined reference to `glutInit'
sam.c.text+0x124): undefined reference to `glutInitDisplayMode'
sam.c.text+0x138): undefined reference to `glutInitWindowSize'
sam.c.text+0x14c): undefined reference to `glutInitWindowPosition'
sam.c.text+0x158): undefined reference to `glutCreateWindow'
sam.c.text+0x17f): undefined reference to `glutDisplayFunc'
sam.c.text+0x184): undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
 
Old 06-03-2007, 12:08 AM   #6
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
What -l flags do you specify? -lGL -lGLU , what else?
 
Old 06-04-2007, 12:04 AM   #7
eerpini
Member
 
Registered: Mar 2007
Posts: 36

Original Poster
Rep: Reputation: 15
i did not understand , do we have to give some flags , i mean i just gave the command :
# gcc sam.c,
and then gcc showed the errors i have mentioned above !
please explain !
 
Old 06-04-2007, 12:08 AM   #8
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Open Graphics Library is an external package (with respect to glibc, gcc, and all core GNU/Linux system). So gcc will never know it should be used in any quality unless you specify it. It installs its header where gcc looks for them by default, but no libraries are linked in unless they are specified or it is libc. So specify '-lGL -lGLU ' to let gcc know you want it to use libGL.so and linGLU.so .
 
Old 06-05-2007, 12:20 AM   #9
eerpini
Member
 
Registered: Mar 2007
Posts: 36

Original Poster
Rep: Reputation: 15
thanks, it works i gaev the following command, ..

# gcc -lGL -lGLU -lglut sam.c


it worked and gave the output( that is a a.out file was created) , but when i run the output it gives the following error
# ./a.out
./a.out: error while loading shared libraries: libglut.so.3: cannot open shared object file: No such file or directory



now what does this mean , the compiler is able to find the libraries but not machine ??

please help me !
 
Old 06-05-2007, 03:07 AM   #10
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Run ldconfig as root.
 
Old 06-06-2007, 12:15 AM   #11
eerpini
Member
 
Registered: Mar 2007
Posts: 36

Original Poster
Rep: Reputation: 15
ya thanks a lot , now i am able to compile and run the code , ........

but is there anyway i could bypass the flags , ....
is it necessary that i give the flags everytime ?


is there no single step solution , so that the programs compile
with just the commmand

# gcc <file>

Last edited by eerpini; 06-06-2007 at 12:18 AM.
 
Old 06-06-2007, 12:27 AM   #12
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
No. Not with just gcc. There is a solution - to use 'make'. In simple cases you can write script that does compilation and place it near code. In complex cases you can use Autotools. You can write a shell script that will run gcc with all libraries you ever use, put it in /usr/bin and call it instead, but it is not very good as your programs will have bigger size and unneeded dependencies.
 
Old 06-07-2007, 01:00 AM   #13
eerpini
Member
 
Registered: Mar 2007
Posts: 36

Original Poster
Rep: Reputation: 15
ya i have done it , just got the required tip from the linux for you magazine ,
i jsut created an alias, using the following command , and alas it works ,.......
# alias ggl='g++ -lGL -lGLU -lGLw -lglut'
# echo "alias ggl='g++ -lGL -lGLU -lGLw -lglut'" >> ~//.bashrc


now running the command
#ggl sample.cpp
compiles the openGL graphics code in the file sample.cpp
......................
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors installing Q, which is needed for Lex, which is needed for PHP Virtuality Linux - Software 1 05-29-2007 04:47 PM
Overwrite Mesa OpenGL with ATI OpenGL Carl-Fredrik Slackware 12 10-01-2004 03:33 PM
Qt 3.3.1 + OpenGL George666 Slackware 0 04-06-2004 09:52 AM
Changing from MESA OpenGL to ATI OpenGL tillyoubreakit Linux - Hardware 19 10-07-2003 07:32 PM
OpenGL is needed by plib-1.7.0- but i have opengl ! qwijibow Linux - Newbie 0 08-05-2003 07:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration