Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 !
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.
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?
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
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 !
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900
Rep:
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 .
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 ??
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900
Rep:
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.
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......................
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.