LinuxQuestions.org
Review your favorite Linux distribution.
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 09-12-2014, 03:15 PM   #1
hnasr2001
Member
 
Registered: Nov 2012
Posts: 98

Rep: Reputation: Disabled
openLG error during compiling with g++


I installed openGL using;
yum install mesa-libGL & yum install mesa-libGL-devel

I tried to compile the following code:
------------------------------------------------------------------------
// A Simple OpenGL Project

#include </GL/glu.h>
#include </GL/gl.h>


void Initialize() {
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

int main(int iArgc, char** cppArgv) {
glutInit(&iArgc, cppArgv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(200, 200);
glutCreateWindow("XoaX.net");
Initialize();
glutDisplayFunc(Draw);
glutMainLoop();
return 0;
}
-------------------------------------------------

I am getting the follwoiung errors;

[root@rpcztc Downloads]# g++ -W -pedantic -o radmon test.cpp
test.cpp:7:21: error: /GL/glu.h: No such file or directory
test.cpp:8:20: error: /GL/gl.h: No such file or directory
test.cpp: In function 'void Initialize()':
test.cpp:12: error: 'glClearColor' was not declared in this scope
test.cpp:13: error: 'GL_PROJECTION' was not declared in this scope
test.cpp:13: error: 'glMatrixMode' was not declared in this scope
test.cpp:14: error: 'glLoadIdentity' was not declared in this scope
test.cpp:15: error: 'glOrtho' was not declared in this scope
test.cpp: In function 'int main(int, char**)':
test.cpp:19: error: 'glutInit' was not declared in this scope
test.cpp:20: error: 'GLUT_SINGLE' was not declared in this scope
test.cpp:20: error: 'GLUT_RGB' was not declared in this scope
test.cpp:20: error: 'glutInitDisplayMode' was not declared in this scope
test.cpp:21: error: 'glutInitWindowSize' was not declared in this scope
test.cpp:22: error: 'glutInitWindowPosition' was not declared in this scope
test.cpp:23: error: 'glutCreateWindow' was not declared in this scope
test.cpp:25: error: 'Draw' was not declared in this scope
test.cpp:25: error: 'glutDisplayFunc' was not declared in this scope
test.cpp:26: error: 'glutMainLoop' was not declared in this scope

I look at the /usr/include/GL and I am able to see the glu.h header!
Any idea what link is missing?
 
Old 09-12-2014, 03:35 PM   #2
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
The includes are wrong use:
Code:
#include <GL/glu.h>
#include <GL/gl.h>
 
1 members found this post helpful.
Old 09-13-2014, 02:26 PM   #3
hnasr2001
Member
 
Registered: Nov 2012
Posts: 98

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by hnasr2001 View Post
I installed openGL using;
yum install mesa-libGL & yum install mesa-libGL-devel

I tried to compile the following code:
------------------------------------------------------------------------
// A Simple OpenGL Project

#include </GL/glu.h>
#include </GL/gl.h>


void Initialize() {
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

int main(int iArgc, char** cppArgv) {
glutInit(&iArgc, cppArgv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(200, 200);
glutCreateWindow("XoaX.net");
Initialize();
glutDisplayFunc(Draw);
glutMainLoop();
return 0;
}
-------------------------------------------------

I am getting the follwoiung errors;

[root@rpcztc Downloads]# g++ -W -pedantic -o radmon test.cpp
test.cpp:7:21: error: /GL/glu.h: No such file or directory
test.cpp:8:20: error: /GL/gl.h: No such file or directory
test.cpp: In function 'void Initialize()':
test.cpp:12: error: 'glClearColor' was not declared in this scope
test.cpp:13: error: 'GL_PROJECTION' was not declared in this scope
test.cpp:13: error: 'glMatrixMode' was not declared in this scope
test.cpp:14: error: 'glLoadIdentity' was not declared in this scope
test.cpp:15: error: 'glOrtho' was not declared in this scope
test.cpp: In function 'int main(int, char**)':
test.cpp:19: error: 'glutInit' was not declared in this scope
test.cpp:20: error: 'GLUT_SINGLE' was not declared in this scope
test.cpp:20: error: 'GLUT_RGB' was not declared in this scope
test.cpp:20: error: 'glutInitDisplayMode' was not declared in this scope
test.cpp:21: error: 'glutInitWindowSize' was not declared in this scope
test.cpp:22: error: 'glutInitWindowPosition' was not declared in this scope
test.cpp:23: error: 'glutCreateWindow' was not declared in this scope
test.cpp:25: error: 'Draw' was not declared in this scope
test.cpp:25: error: 'glutDisplayFunc' was not declared in this scope
test.cpp:26: error: 'glutMainLoop' was not declared in this scope

I look at the /usr/include/GL and I am able to see the glu.h header!
Any idea what link is missing?

I made the changes to the header path;
#include <GL/glu.h>
#include <GL/gl.h>

Still I am getting the same error!!
 
Old 09-13-2014, 03:50 PM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Quote:
I installed openGL ...
yum install mesa-libGL & yum install mesa-libGL-devel
You are missing some packages : *GLU-devel, *glut-devel ...

# yum install mesa-libGLU-devel freeglut-devel
 
Old 09-13-2014, 05:18 PM   #5
hnasr2001
Member
 
Registered: Nov 2012
Posts: 98

Original Poster
Rep: Reputation: Disabled
I had installed mesa-libGL-devel;

The errors are;

[root@localhost Desktop]# g++ -W -pedantic -o radmon test.cpp
test.cpp:1:20: error: GL/glu.h: No such file or directory
test.cpp: In function int main(int, char**):
test.cpp:13: error: glutInit was not declared in this scope
test.cpp:14: error: GLUT_SINGLE was not declared in this scope
test.cpp:14: error: GLUT_RGB was not declared in this scope
test.cpp:14: error: glutInitDisplayMode was not declared in this scope
test.cpp:15: error: glutInitWindowSize was not declared in this scope
test.cpp:16: error: glutInitWindowPosition was not declared in this scope
test.cpp:17: error: glutCreateWindow was not declared in this scope
test.cpp:19: error: Draw was not declared in this scope
test.cpp:19: error: glutDisplayFun was not declared in this scope
test.cpp:20: error: glutMainLoop was not declared in this scope
 
Old 09-13-2014, 05:30 PM   #6
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Now install libGLU-devel and you should be good to go.
 
Old 09-14-2014, 01:52 AM   #7
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Ref. #5.

Read post #4 : # yum install mesa-libGLU-devel freeglut-devel
 
Old 09-14-2014, 01:23 PM   #8
hnasr2001
Member
 
Registered: Nov 2012
Posts: 98

Original Poster
Rep: Reputation: Disabled
To knudfl and metaschima;
As you can see below, I had installed both of the packages you were referring to and still I am getting error!!


[root@localhost ~]# yum install freeglut-devel
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: centos.mirror.rafal.ca
* extras: centos.mirror.rafal.ca
* updates: centos.cubiculestudio.com
Setting up Install Process
Package freeglut-devel-2.4.0-7.1.el5.i386 already installed and latest version
Nothing to do

[root@localhost ~]# yum install libGLU-devel
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: centos.mirror.rafal.ca
* extras: centos.mirror.rafal.ca
* updates: centos.cubiculestudio.com
Setting up Install Process
Package mesa-libGLU-devel-6.5.1-7.11.el5_9.i386 already installed and latest version
Nothing to do

[root@localhost ~]# pwd
/root
[root@localhost ~]# cd Desktop/
[root@localhost Desktop]# ls
C++ eclipse test.cpp test.cpp~ test.sh test.sh~ Unsaved Document 1

[root@localhost Desktop]# g++ test.cpp -o radmon
test.cpp: In function ‘int main(int, char**)’:
test.cpp:13: error: ‘glutInit’ was not declared in this scope
test.cpp:14: error: ‘GLUT_SINGLE’ was not declared in this scope
test.cpp:14: error: ‘GLUT_RGB’ was not declared in this scope
test.cpp:14: error: ‘glutInitDisplayMode’ was not declared in this scope
test.cpp:15: error: ‘glutInitWindowSize’ was not declared in this scope
test.cpp:16: error: ‘glutInitWindowPosition’ was not declared in this scope
test.cpp:17: error: ‘glutCreateWindow’ was not declared in this scope
test.cpp:19: error: ‘Draw’ was not declared in this scope
test.cpp:19: error: ‘glutDisplayFunc’ was not declared in this scope
test.cpp:20: error: ‘glutMainLoop’ was not declared in this scope
 
Old 09-14-2014, 02:08 PM   #9
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
You seem to be using GLUT functions without including the header, so add:
Code:
#include <GL/glut.h>
 
1 members found this post helpful.
Old 09-14-2014, 04:20 PM   #10
hnasr2001
Member
 
Registered: Nov 2012
Posts: 98

Original Poster
Rep: Reputation: Disabled
Thanks adding #include <GL/glut.h> was indeed the problem.

Do you know if the openGL is an easy tool to design drop down menu in c++?

Last edited by hnasr2001; 09-14-2014 at 05:19 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] compiling amuc 1.7 error (help me understand and debug) error: taking address of temporary array marbangens Programming 8 04-25-2013 11:29 AM
Fedora 9: error when compiling flash plug-in with error failed dependencies seow_ming Fedora 2 06-17-2008 07:17 PM
Error when compiling kernel linux-2.6.22 : make: ***[_modinst_post] Error 137 ngoclan.it Linux - General 1 12-11-2007 06:54 AM
Error when compiling kernel linux-2.6.22 : make: ***[_modinst_post] Error 137 ngoclan.it Linux - Newbie 0 12-11-2007 06:49 AM
i get an error ./term.c :95 error conflicting types of tpam when compiling bitchx eveningblush Programming 0 03-30-2006 06:46 AM

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

All times are GMT -5. The time now is 01: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