LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   openLG error during compiling with g++ (https://www.linuxquestions.org/questions/linux-software-2/openlg-error-during-compiling-with-g-4175518399/)

hnasr2001 09-12-2014 03:15 PM

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?

metaschima 09-12-2014 03:35 PM

The includes are wrong use:
Code:

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


hnasr2001 09-13-2014 02:26 PM

Quote:

Originally Posted by hnasr2001 (Post 5236995)
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!!

knudfl 09-13-2014 03:50 PM

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

hnasr2001 09-13-2014 05:18 PM

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

metaschima 09-13-2014 05:30 PM

Now install libGLU-devel and you should be good to go.

knudfl 09-14-2014 01:52 AM

Ref. #5.

Read post #4 : # yum install mesa-libGLU-devel freeglut-devel

hnasr2001 09-14-2014 01:23 PM

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

metaschima 09-14-2014 02:08 PM

You seem to be using GLUT functions without including the header, so add:
Code:

#include <GL/glut.h>

hnasr2001 09-14-2014 04:20 PM

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++?


All times are GMT -5. The time now is 07:52 AM.