Beginner problem with GL, GLEW and GLFW on Linux

Hi,

I’ve asked all over IRC and I’ve got nothing. I’m a beginner to GL (so please ignore the rubbish code!) and am still learning.

I’m wanting to build a 3D simulation for Linux / Windows. I’m developing on Arch Linux. My programming language is Vala (in case you don’t know, Vala is a C#-syntax-like language that translates to C before being compiled. If you don’t know it, it doesn’t matter. If a noob like me can handle it then it’s fine). However, after a lot of internet search that didn’t help me solve the problem, I have established that the issue is probably not Vala, and is infact GL / GLEW / GLU / GLFW itself.

So I have this code:


using GLib;
using GLU;
using GL;
using Math;
using GLFW;

namespace GLib
{
	class MainClass : Object
	{
		public static int main(string[] args)
		{
			//initiate GLFW
			GLFW.init();
			
			//Define initial variables
			int width = 640;
			int height = 480;
			
			//Create the window
			GLFW.Window window = new GLFW.Window(width, height, "Hello, World!", null, null);
			
			//Make the window OpenGL context the current one
			window.make_context_current();
			
			//Main loop
			while (window.should_close == false)
			{
				//[DRAW GOES HERE]
				GL.glEnable(GL.GL_TEXTURE_2D);
				GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
				GL.glViewport(0, 0, width, height);
				GL.glClear(GL.GL_COLOR_BUFFER_BIT);
				
				GL.glMatrixMode(GL.GL_PROJECTION);
				GL.glLoadIdentity();
				
				GL.glOrtho(0.0f, width, height, 0.0f, -1.0f, 1.0f);
				
				GL.glMatrixMode(GL.GL_MODELVIEW);
				GL.glLoadIdentity();
				
				//Swap the buffers to render
				window.swap_buffers();
				//Check for events
				GLFW.poll_events();
			}
			
			//Close the window
			GLFW.terminate();
			
			return 0;
		}
	}
}

And I have compiled it with this command (just the Vala compiler. The --pkg bits are including Vala bindings to these libraries)


valac --vapidir=vapi --pkg glu --pkg glfw3 --pkg gl -o test src/test.vala

However, when doing so, I get this error:


In file included from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:10:0:
/usr/include/GL/glew.h:84:2: error: #error gl.h included before glew.h
 #error gl.h included before glew.h
  ^
/usr/include/GL/glew.h:96:2: error: #error glext.h included before glew.h
 #error glext.h included before glew.h
  ^
In file included from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:10:0:
/usr/include/GL/glew.h:14372:28: error: conflicting types for ‘PFNGLFRAGMENTLIGHTMODELFVSGIXPROC’
 typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat* params);
                            ^
In file included from /usr/include/GL/gl.h:2055:0,
                 from /usr/include/GLFW/glfw3.h:162,
                 from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:9:
/usr/include/GL/glext.h:10626:25: note: previous declaration of ‘PFNGLFRAGMENTLIGHTMODELFVSGIXPROC’ was here
 typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params);
                         ^
In file included from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:10:0:
/usr/include/GL/glew.h:14374:28: error: conflicting types for ‘PFNGLFRAGMENTLIGHTMODELIVSGIXPROC’
 typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint* params);
                            ^
In file included from /usr/include/GL/gl.h:2055:0,
                 from /usr/include/GLFW/glfw3.h:162,
                 from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:9:
/usr/include/GL/glext.h:10628:25: note: previous declaration of ‘PFNGLFRAGMENTLIGHTMODELIVSGIXPROC’ was here
 typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params);
                         ^
In file included from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:10:0:
/usr/include/GL/glew.h:14376:28: error: conflicting types for ‘PFNGLFRAGMENTLIGHTFVSGIXPROC’
 typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params);
                            ^
In file included from /usr/include/GL/gl.h:2055:0,
                 from /usr/include/GLFW/glfw3.h:162,
                 from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:9:
/usr/include/GL/glext.h:10622:25: note: previous declaration of ‘PFNGLFRAGMENTLIGHTFVSGIXPROC’ was here
 typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);
                         ^
In file included from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:10:0:
/usr/include/GL/glew.h:14378:28: error: conflicting types for ‘PFNGLFRAGMENTLIGHTIVSGIXPROC’
 typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint* params);
                            ^
In file included from /usr/include/GL/gl.h:2055:0,
                 from /usr/include/GLFW/glfw3.h:162,
                 from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:9:
/usr/include/GL/glext.h:10624:25: note: previous declaration of ‘PFNGLFRAGMENTLIGHTIVSGIXPROC’ was here
 typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params);
                         ^
In file included from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:10:0:
/usr/include/GL/glew.h:14385:28: error: conflicting types for ‘PFNGLGETFRAGMENTMATERIALFVSGIXPROC’
 typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* data);
                            ^
In file included from /usr/include/GL/gl.h:2055:0,
                 from /usr/include/GLFW/glfw3.h:162,
                 from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:9:
/usr/include/GL/glext.h:10635:25: note: previous declaration of ‘PFNGLGETFRAGMENTMATERIALFVSGIXPROC’ was here
 typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params);
                         ^
In file included from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:10:0:
/usr/include/GL/glew.h:14386:28: error: conflicting types for ‘PFNGLGETFRAGMENTMATERIALIVSGIXPROC’
 typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data);
                            ^
In file included from /usr/include/GL/gl.h:2055:0,
                 from /usr/include/GLFW/glfw3.h:162,
                 from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:9:
/usr/include/GL/glext.h:10636:25: note: previous declaration of ‘PFNGLGETFRAGMENTMATERIALIVSGIXPROC’ was here
 typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params);
                         ^
In file included from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:10:0:
/usr/include/GL/glew.h:15049:17: error: unknown type name ‘PFNGLCLIENTACTIVETEXTUREPROC’
 GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture;
                 ^
/usr/include/GL/glew.h:15057:17: error: unknown type name ‘PFNGLLOADTRANSPOSEMATRIXDPROC’
 GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd;
                 ^
/usr/include/GL/glew.h:15058:17: error: unknown type name ‘PFNGLLOADTRANSPOSEMATRIXFPROC’
 GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf;
                 ^
/usr/include/GL/glew.h:15059:17: error: unknown type name ‘PFNGLMULTTRANSPOSEMATRIXDPROC’
 GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd;
                 ^
/usr/include/GL/glew.h:15060:17: error: unknown type name ‘PFNGLMULTTRANSPOSEMATRIXFPROC’
 GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf;
                 ^
/usr/include/GL/glew.h:15061:17: error: unknown type name ‘PFNGLMULTITEXCOORD1DPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d;
                 ^
/usr/include/GL/glew.h:15062:17: error: unknown type name ‘PFNGLMULTITEXCOORD1DVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv;
                 ^
/usr/include/GL/glew.h:15063:17: error: unknown type name ‘PFNGLMULTITEXCOORD1FPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f;
                 ^
/usr/include/GL/glew.h:15064:17: error: unknown type name ‘PFNGLMULTITEXCOORD1FVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv;
                 ^
/usr/include/GL/glew.h:15065:17: error: unknown type name ‘PFNGLMULTITEXCOORD1IPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i;
                 ^
/usr/include/GL/glew.h:15066:17: error: unknown type name ‘PFNGLMULTITEXCOORD1IVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv;
                 ^
/usr/include/GL/glew.h:15067:17: error: unknown type name ‘PFNGLMULTITEXCOORD1SPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s;
                 ^
/usr/include/GL/glew.h:15068:17: error: unknown type name ‘PFNGLMULTITEXCOORD1SVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv;
                 ^
/usr/include/GL/glew.h:15069:17: error: unknown type name ‘PFNGLMULTITEXCOORD2DPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d;
                 ^
/usr/include/GL/glew.h:15070:17: error: unknown type name ‘PFNGLMULTITEXCOORD2DVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv;
                 ^
/usr/include/GL/glew.h:15071:17: error: unknown type name ‘PFNGLMULTITEXCOORD2FPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f;
                 ^
/usr/include/GL/glew.h:15072:17: error: unknown type name ‘PFNGLMULTITEXCOORD2FVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv;
                 ^
/usr/include/GL/glew.h:15073:17: error: unknown type name ‘PFNGLMULTITEXCOORD2IPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i;
                 ^
/usr/include/GL/glew.h:15074:17: error: unknown type name ‘PFNGLMULTITEXCOORD2IVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv;
                 ^
/usr/include/GL/glew.h:15075:17: error: unknown type name ‘PFNGLMULTITEXCOORD2SPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s;
                 ^
/usr/include/GL/glew.h:15076:17: error: unknown type name ‘PFNGLMULTITEXCOORD2SVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv;
                 ^
/usr/include/GL/glew.h:15077:17: error: unknown type name ‘PFNGLMULTITEXCOORD3DPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d;
                 ^
/usr/include/GL/glew.h:15078:17: error: unknown type name ‘PFNGLMULTITEXCOORD3DVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv;
                 ^
/usr/include/GL/glew.h:15079:17: error: unknown type name ‘PFNGLMULTITEXCOORD3FPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f;
                 ^
/usr/include/GL/glew.h:15080:17: error: unknown type name ‘PFNGLMULTITEXCOORD3FVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv;
                 ^
/usr/include/GL/glew.h:15081:17: error: unknown type name ‘PFNGLMULTITEXCOORD3IPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i;
                 ^
/usr/include/GL/glew.h:15082:17: error: unknown type name ‘PFNGLMULTITEXCOORD3IVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv;
                 ^
/usr/include/GL/glew.h:15083:17: error: unknown type name ‘PFNGLMULTITEXCOORD3SPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s;
                 ^
/usr/include/GL/glew.h:15084:17: error: unknown type name ‘PFNGLMULTITEXCOORD3SVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv;
                 ^
/usr/include/GL/glew.h:15085:17: error: unknown type name ‘PFNGLMULTITEXCOORD4DPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d;
                 ^
/usr/include/GL/glew.h:15086:17: error: unknown type name ‘PFNGLMULTITEXCOORD4DVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv;
                 ^
/usr/include/GL/glew.h:15087:17: error: unknown type name ‘PFNGLMULTITEXCOORD4FPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f;
                 ^
/usr/include/GL/glew.h:15088:17: error: unknown type name ‘PFNGLMULTITEXCOORD4FVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv;
                 ^
/usr/include/GL/glew.h:15089:17: error: unknown type name ‘PFNGLMULTITEXCOORD4IPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i;
                 ^
/usr/include/GL/glew.h:15090:17: error: unknown type name ‘PFNGLMULTITEXCOORD4IVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv;
                 ^
/usr/include/GL/glew.h:15091:17: error: unknown type name ‘PFNGLMULTITEXCOORD4SPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s;
                 ^
/usr/include/GL/glew.h:15092:17: error: unknown type name ‘PFNGLMULTITEXCOORD4SVPROC’
 GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv;
                 ^
/usr/include/GL/glew.h:15572:17: error: unknown type name ‘PFNGLCOLORSUBTABLEPROC’
 GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEPROC __glewColorSubTable;
                 ^
/usr/include/GL/glew.h:15573:17: error: unknown type name ‘PFNGLCOLORTABLEPROC’
 GLEW_FUN_EXPORT PFNGLCOLORTABLEPROC __glewColorTable;
                 ^
/usr/include/GL/glew.h:15574:17: error: unknown type name ‘PFNGLCOLORTABLEPARAMETERFVPROC’
 GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv;
                 ^
/usr/include/GL/glew.h:15575:17: error: unknown type name ‘PFNGLCOLORTABLEPARAMETERIVPROC’
 GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv;
                 ^
/usr/include/GL/glew.h:15576:17: error: unknown type name ‘PFNGLCONVOLUTIONFILTER1DPROC’
 GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D;
                 ^
/usr/include/GL/glew.h:15577:17: error: unknown type name ‘PFNGLCONVOLUTIONFILTER2DPROC’
 GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D;
                 ^
/usr/include/GL/glew.h:15578:17: error: unknown type name ‘PFNGLCONVOLUTIONPARAMETERFPROC’
 GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf;
                 ^
/usr/include/GL/glew.h:15579:17: error: unknown type name ‘PFNGLCONVOLUTIONPARAMETERFVPROC’
 GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv;
                 ^
/usr/include/GL/glew.h:15580:17: error: unknown type name ‘PFNGLCONVOLUTIONPARAMETERIPROC’
 GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri;
                 ^
/usr/include/GL/glew.h:15581:17: error: unknown type name ‘PFNGLCONVOLUTIONPARAMETERIVPROC’
 GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv;
                 ^
/usr/include/GL/glew.h:15582:17: error: unknown type name ‘PFNGLCOPYCOLORSUBTABLEPROC’
 GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable;
                 ^
/usr/include/GL/glew.h:15583:17: error: unknown type name ‘PFNGLCOPYCOLORTABLEPROC’
 GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable;
                 ^
/usr/include/GL/glew.h:15584:17: error: unknown type name ‘PFNGLCOPYCONVOLUTIONFILTER1DPROC’
 GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D;
                 ^
/usr/include/GL/glew.h:15585:17: error: unknown type name ‘PFNGLCOPYCONVOLUTIONFILTER2DPROC’
 GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D;
                 ^
/usr/include/GL/glew.h:15586:17: error: unknown type name ‘PFNGLGETCOLORTABLEPROC’
 GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPROC __glewGetColorTable;
                 ^
/usr/include/GL/glew.h:15587:17: error: unknown type name ‘PFNGLGETCOLORTABLEPARAMETERFVPROC’
 GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv;
                 ^
/usr/include/GL/glew.h:15588:17: error: unknown type name ‘PFNGLGETCOLORTABLEPARAMETERIVPROC’
 GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv;
                 ^
/usr/include/GL/glew.h:15589:17: error: unknown type name ‘PFNGLGETCONVOLUTIONFILTERPROC’
 GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter;
                 ^
/usr/include/GL/glew.h:15590:17: error: unknown type name ‘PFNGLGETCONVOLUTIONPARAMETERFVPROC’
 GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv;
                 ^
/usr/include/GL/glew.h:15591:17: error: unknown type name ‘PFNGLGETCONVOLUTIONPARAMETERIVPROC’
 GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv;
                 ^
/usr/include/GL/glew.h:15592:17: error: unknown type name ‘PFNGLGETHISTOGRAMPROC’
 GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPROC __glewGetHistogram;
                 ^
/usr/include/GL/glew.h:15593:17: error: unknown type name ‘PFNGLGETHISTOGRAMPARAMETERFVPROC’
 GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv;
                 ^
/usr/include/GL/glew.h:15594:17: error: unknown type name ‘PFNGLGETHISTOGRAMPARAMETERIVPROC’
 GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv;
                 ^
/usr/include/GL/glew.h:15595:17: error: unknown type name ‘PFNGLGETMINMAXPROC’
 GLEW_FUN_EXPORT PFNGLGETMINMAXPROC __glewGetMinmax;
                 ^
/usr/include/GL/glew.h:15596:17: error: unknown type name ‘PFNGLGETMINMAXPARAMETERFVPROC’
 GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv;
                 ^
/usr/include/GL/glew.h:15597:17: error: unknown type name ‘PFNGLGETMINMAXPARAMETERIVPROC’
 GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv;
                 ^
/usr/include/GL/glew.h:15598:17: error: unknown type name ‘PFNGLGETSEPARABLEFILTERPROC’
 GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter;
                 ^
/usr/include/GL/glew.h:15599:17: error: unknown type name ‘PFNGLHISTOGRAMPROC’
 GLEW_FUN_EXPORT PFNGLHISTOGRAMPROC __glewHistogram;
                 ^
/usr/include/GL/glew.h:15600:17: error: unknown type name ‘PFNGLMINMAXPROC’
 GLEW_FUN_EXPORT PFNGLMINMAXPROC __glewMinmax;
                 ^
/usr/include/GL/glew.h:15601:17: error: unknown type name ‘PFNGLRESETHISTOGRAMPROC’
 GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMPROC __glewResetHistogram;
                 ^
/usr/include/GL/glew.h:15602:17: error: unknown type name ‘PFNGLRESETMINMAXPROC’
 GLEW_FUN_EXPORT PFNGLRESETMINMAXPROC __glewResetMinmax;
                 ^
/usr/include/GL/glew.h:15603:17: error: unknown type name ‘PFNGLSEPARABLEFILTER2DPROC’
 GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D;
                 ^
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

Does anyone know what might be the issue? I’m fairly sure the bindings I have to Vala for these libraries are good, so it should all be working.

Thanks very much for reading,

Barry Smith (Zesterer)

[QUOTE=zesterer;1260405]So I have this code:


using GLib;
using GLU;
using GL;
using Math;
using GLFW;
...

And I have compiled it with this command … However, when doing so, I get this error:


In file included from /home/barry/Documents/SoftwareProjects/voxel-engine/src/test.vala.c:10:0:
/usr/include/GL/glew.h:84:2: error: #error gl.h included before glew.h
 #error gl.h included before glew.h
  ^
/usr/include/GL/glew.h:96:2: error: #error glext.h included before glew.h
 #error glext.h included before glew.h
  ^

[/QUOTE]

Well, if this Vala language is going to make you deal with C/C++ compiler errors, it better expose a way to look a the generated C/C++ before compilation.

If you look at it, you’ll no doubt find exactly what the error says to be the case.

Best guess: the C/C++ #includes are probably generated in the same order as the using directives in your Vala code. Try reording your using directives as follows:


using GLFW;
using GLib;
using GLU;
using GL;
using Math;

[QUOTE=Dark Photon;1260406]Well, if this Vala language is going to make you deal with C/C++ compiler errors, it better expose a way to look a the generated C/C++ before compilation.

If you look at it, you’ll no doubt find exactly what the error says to be the case.

Best guess: the C/C++ #includes are probably generated in the same order as the using directives in your Vala code. Try reording your using directives as follows:


using GLFW;
using GLib;
using GLU;
using GL;
using Math;

[/QUOTE]

Ok, so I added the “-C” tag to the compiler that makes it output the generated C beforehand, and I got this C file…


/* test.c generated by valac 0.24.0, the Vala compiler
 * generated from test.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <GLFW/glfw3.h>
#include <GL/glew.h>


#define G_TYPE_MAINCLASS (g_mainclass_get_type ())
#define G_MAINCLASS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_MAINCLASS, GMainClass))
#define G_MAINCLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_MAINCLASS, GMainClassClass))
#define G_IS_MAINCLASS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_MAINCLASS))
#define G_IS_MAINCLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_MAINCLASS))
#define G_MAINCLASS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_MAINCLASS, GMainClassClass))

typedef struct _GMainClass GMainClass;
typedef struct _GMainClassClass GMainClassClass;
typedef struct _GMainClassPrivate GMainClassPrivate;
#define _glfwDestroyWindow0(var) ((var == NULL) ? NULL : (var = (glfwDestroyWindow (var), NULL)))

struct _GMainClass {
	GObject parent_instance;
	GMainClassPrivate * priv;
};

struct _GMainClassClass {
	GObjectClass parent_class;
};


static gpointer g_mainclass_parent_class = NULL;

GType g_mainclass_get_type (void) G_GNUC_CONST;
enum  {
	G_MAINCLASS_DUMMY_PROPERTY
};
gint g_mainclass_main (gchar** args, int args_length1);
GMainClass* g_mainclass_new (void);
GMainClass* g_mainclass_construct (GType object_type);


gint g_mainclass_main (gchar** args, int args_length1) {
	gint result = 0;
	gint width = 0;
	gint height = 0;
	GLFWwindow* window = NULL;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	GLFWwindow* _tmp2_ = NULL;
	GLFWwindow* _tmp3_ = NULL;
	glfwInit ();
	width = 640;
	height = 480;
	_tmp0_ = width;
	_tmp1_ = height;
	_tmp2_ = glfwCreateWindow (_tmp0_, _tmp1_, "Hello, World!", NULL, NULL);
	window = _tmp2_;
	_tmp3_ = window;
	glfwMakeContextCurrent (_tmp3_);
	while (TRUE) {
		GLFWwindow* _tmp4_ = NULL;
		gboolean _tmp5_ = FALSE;
		gboolean _tmp6_ = FALSE;
		gint _tmp7_ = 0;
		gint _tmp8_ = 0;
		gint _tmp9_ = 0;
		gint _tmp10_ = 0;
		GLFWwindow* _tmp11_ = NULL;
		_tmp4_ = window;
		_tmp5_ = glfwWindowShouldClose (_tmp4_);
		_tmp6_ = _tmp5_;
		if (!(_tmp6_ == FALSE)) {
			break;
		}
		glEnable ((GLenum) GL_TEXTURE_2D);
		glClearColor ((GLfloat) 0.0f, (GLfloat) 0.0f, (GLfloat) 0.0f, (GLfloat) 0.0f);
		_tmp7_ = width;
		_tmp8_ = height;
		glViewport ((GLint) 0, (GLint) 0, (GLsizei) _tmp7_, (GLsizei) _tmp8_);
		glClear ((GLbitfield) GL_COLOR_BUFFER_BIT);
		glMatrixMode ((GLenum) GL_PROJECTION);
		glLoadIdentity ();
		_tmp9_ = width;
		_tmp10_ = height;
		glOrtho ((GLdouble) 0.0f, (GLdouble) _tmp9_, (GLdouble) _tmp10_, (GLdouble) 0.0f, (GLdouble) (-1.0f), (GLdouble) 1.0f);
		glMatrixMode ((GLenum) GL_MODELVIEW);
		glLoadIdentity ();
		_tmp11_ = window;
		glfwSwapBuffers (_tmp11_);
		glfwPollEvents ();
	}
	glfwTerminate ();
	result = 0;
	_glfwDestroyWindow0 (window);
	return result;
}


int main (int argc, char ** argv) {
#if !GLIB_CHECK_VERSION (2,35,0)
	g_type_init ();
#endif
	return g_mainclass_main (argv, argc);
}


GMainClass* g_mainclass_construct (GType object_type) {
	GMainClass * self = NULL;
	self = (GMainClass*) g_object_new (object_type, NULL);
	return self;
}


GMainClass* g_mainclass_new (void) {
	return g_mainclass_construct (G_TYPE_MAINCLASS);
}


static void g_mainclass_class_init (GMainClassClass * klass) {
	g_mainclass_parent_class = g_type_class_peek_parent (klass);
}


static void g_mainclass_instance_init (GMainClass * self) {
}


GType g_mainclass_get_type (void) {
	static volatile gsize g_mainclass_type_id__volatile = 0;
	if (g_once_init_enter (&g_mainclass_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GMainClassClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) g_mainclass_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GMainClass), 0, (GInstanceInitFunc) g_mainclass_instance_init, NULL };
		GType g_mainclass_type_id;
		g_mainclass_type_id = g_type_register_static (G_TYPE_OBJECT, "GMainClass", &g_define_type_info, 0);
		g_once_init_leave (&g_mainclass_type_id__volatile, g_mainclass_type_id);
	}
	return g_mainclass_type_id__volatile;
}

I see that it’s including things in the wrong order… But I have no idea how to go about fixing this :sorrow:

I can’t modify this file, it won’t generate correctly. But I see the problem here is probably Vala, so I’ll try fixing it another way.

Thanks for your help!

Barry Smith (Zesterer)