PDA

View Full Version : issue with math_3d.h



dark_ninjuh
06-29-2014, 01:31 PM
OS:ubuntu 12.04 Lts
IDE:CodeBlocks

im trying to include math_3d.h in my glew/freeglut project and seem to be having some issues
at first attempt to include it i got "no such file or directory"

so then i google and found a math_3d to include

svn-history/r75/trunk/tutorial36/math_3d.h (<--bing or google that. new users cant post links)

after including this file it just returned many errors

/home/dark_ninjuh/Desktop/l/main.c|1|warning: extra tokens at end of #ifndef directive [enabled by default]|
/home/dark_ninjuh/Desktop/l/math_3d.h|41|error: expected specifier-qualifier-list before ‘Vector2f’|
/home/dark_ninjuh/Desktop/l/math_3d.h|59|error: expected specifier-qualifier-list before ‘Vector3f’|
/home/dark_ninjuh/Desktop/l/math_3d.h|117|error: expected specifier-qualifier-list before ‘Vector4f’|
/home/dark_ninjuh/Desktop/l/math_3d.h|135|error: unknown type name ‘Vector3f’|
/home/dark_ninjuh/Desktop/l/math_3d.h|135|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘+’ token|
/home/dark_ninjuh/Desktop/l/math_3d.h|144|error: unknown type name ‘Vector3f’|
/home/dark_ninjuh/Desktop/l/math_3d.h|144|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘-’ token|
/home/dark_ninjuh/Desktop/l/math_3d.h|153|error: unknown type name ‘Vector3f’|
/home/dark_ninjuh/Desktop/l/math_3d.h|153|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token|
/home/dark_ninjuh/Desktop/l/math_3d.h|171|error: unknown type name ‘class’|
/home/dark_ninjuh/Desktop/l/math_3d.h|172|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token|
/home/dark_ninjuh/Desktop/l/math_3d.h|250|error: expected specifier-qualifier-list before ‘Quaternion’|
/home/dark_ninjuh/Desktop/l/math_3d.h|257|error: unknown type name ‘Quaternion’|
/home/dark_ninjuh/Desktop/l/math_3d.h|257|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token|
/home/dark_ninjuh/Desktop/l/math_3d.h|259|error: unknown type name ‘Quaternion’|
/home/dark_ninjuh/Desktop/l/math_3d.h|259|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token|
/home/dark_ninjuh/Desktop/l/main.c|1|error: unterminated #ifndef|
/home/dark_ninjuh/Desktop/l/main.c||In function ‘main’:|
/home/dark_ninjuh/Desktop/l/main.c|27|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build finished: 17 errors, 2 warnings ===|



here is my main source if it helps:
#ifndef LOPENGL_H #define LOPENGL_H

#include <stdio.h>
#include <GL/glew.h>
#include <GL/freeglut.h>
#include "math_3d.h"


void display (void) {
glClearColor(1.0f, 0.0f, 0.0f, 1.0f); // Clear the background of our window to red
glClear(GL_COLOR_BUFFER_BIT); //Clear the colour buffer (more buffers later on)
glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations

glFlush(); // Flush the OpenGL buffers to the window
}

int main (int argc, char **argv) {
glutInit(&argc, argv); // Initialize GLUT
glutInitDisplayMode (GLUT_SINGLE); // Set up a basic display buffer (only single buffered for now)
glutInitWindowSize (500, 500); // Set the width and height of the window
glutInitWindowPosition (100, 100); // Set the position of the window
glutCreateWindow ("Your first OpenGL Window"); // Set the title for the window

glutDisplayFunc(display); // Tell GLUT to use the method "display" for rendering

glutMainLoop(); // Enter GLUT's main loop
}

any guidence in the right direction is appreciated

Agent D
06-29-2014, 03:29 PM
I took a look at the header here (http://ogldev.googlecode.com/svn-history/r75/trunk/tutorial36/math_3d.h). Is that it?

Anyway, it's C++ and your translation unit is called "main.c". Are you trying to feed C++ through a C compiler?

dark_ninjuh
06-29-2014, 04:16 PM
The reason i over looked it was because i went to: file->new project-> opengl
and by default it creates the main source as main.c

if any one made the same mistake and is trying to get math_3d.h freeglut/glew working here are the steps
OS:ubuntu 12.04
IDE:CodeBlocks
file->new project->empty project

create a main.cpp

add the math_3d.h into project directory

link your include by going to project->properties->projects build options -> Linker settings -> other linker options:
and paste "-lGL -lGLU -lglut" without the quotes.

compile and run and it should be working.

thanks for this forums support :)