Hi guys,
I recently discovered sublime text 2 and i am loving it, i am starting to learn c++ and opengl so my query is how can i build a opengl code with cpp from sublime’s build menu, since i am trying to build the same and i get errors
i am using this Build File
[code]{
“cmd”: “g++”, “${file}”, “-o”, “${file_path}/${file_base_name}”],
“file_regex”: “^(…^:]):([0-9]+):?([0-9]+)?:? (.)$”,
“working_dir”: “${file_path}”,
“selector”: “source.c, source.c++”,
"variants":
{
"name": "Run",
"cmd": "${file_path}/${file_base_name}.exe"]
}
]
}[/code]
and building this cpp code
[code]#include <GL/glut.h>
void render(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0, 0, -30);
// Green Sphere
glPushMatrix();
glColor3f(0.6, 0.9, 0);
glTranslatef(7, -5, 0);
glutSolidSphere(5, 50, 50);
glPopMatrix();
// Blue Cube
glPushMatrix();
glColor3f(0.0, 0.5, 0.9);
glTranslatef(0, 5, 0);
glRotatef(45, 1, 0, 0);
glRotatef(45, 0, 1, 0);
glutSolidCube(8);
glPopMatrix();
// Violet Cone
glPushMatrix();
glColor3f(0.7, 0.0, 1.0);
glTranslatef(-7, -5, 0);
glRotatef(-65, 0, 1, 0);
glRotatef(-65, 1, 0, 1);
glutSolidCone(5, 10, 100, 100);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void init(void)
{
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glClearDepth( 1.0 );
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glShadeModel(GL_SMOOTH);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_LIGHT0);
}
void reshape(int w, int h)
{
float aspectRatio = (float)w/(float)h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, aspectRatio, 1.0, 100.0);
glMatrixMode(GL_MODELVIEW);
}
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
glutInitWindowSize(400, 300);
glutCreateWindow(“GLUT on Sublime Text”);
init();
glutReshapeFunc(reshape);
glutDisplayFunc(render);
glutMainLoop();
return 0;
}[/code]
i get long list of errors
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x1c): undefined reference to `__glutInitWithExit'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x37): undefined reference to `__glutCreateWindowWithExit'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x52): undefined reference to `__glutCreateMenuWithExit'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x66): undefined reference to `_imp__glClear'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x6d): undefined reference to `_imp__glLoadIdentity'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x8e): undefined reference to `_imp__glTranslatef'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x95): undefined reference to `_imp__glPushMatrix'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0xb6): undefined reference to `_imp__glColor3f'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0xd7): undefined reference to `_imp__glTranslatef'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0xff): undefined reference to `glutSolidSphere'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x104): undefined reference to `_imp__glPopMatrix'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x10b): undefined reference to `_imp__glPushMatrix'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x12c): undefined reference to `_imp__glColor3f'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x14d): undefined reference to `_imp__glTranslatef'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x177): undefined reference to `_imp__glRotatef'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x1a1): undefined reference to `_imp__glRotatef'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x1b9): undefined reference to `glutSolidCube'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x1be): undefined reference to `_imp__glPopMatrix'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x1c5): undefined reference to `_imp__glPushMatrix'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x1e6): undefined reference to `_imp__glColor3f'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x207): undefined reference to `_imp__glTranslatef'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x231): undefined reference to `_imp__glRotatef'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x25b): undefined reference to `_imp__glRotatef'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x295): undefined reference to `glutSolidCone'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x29a): undefined reference to `_imp__glPopMatrix'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x2a1): undefined reference to `_imp__glFlush'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x2a8): undefined reference to `glutSwapBuffers'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x2d8): undefined reference to `_imp__glClearColor'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x2f0): undefined reference to `_imp__glClearDepth'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x2fe): undefined reference to `_imp__glEnable'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x30c): undefined reference to `_imp__glEnable'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x31a): undefined reference to `_imp__glShadeModel'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x328): undefined reference to `_imp__glEnable'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x33e): undefined reference to `_imp__glColorMaterial'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x34c): undefined reference to `_imp__glEnable'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x36d): undefined reference to `_imp__glMatrixMode'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x374): undefined reference to `_imp__glLoadIdentity'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x3b7): undefined reference to `_imp__gluPerspective'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x3c5): undefined reference to `_imp__glMatrixMode'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x3f5): undefined reference to `glutInitDisplayMode'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x409): undefined reference to `glutInitWindowSize'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x426): undefined reference to `glutReshapeFunc'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x432): undefined reference to `glutDisplayFunc'
C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o:simpleGlut.cpp:(.text+0x437): undefined reference to `glutMainLoop'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: C:\Users\HARIOM~1\AppData\Local\Temp\cceovWVy.o: bad reloc address 0x20 in section `.eh_frame'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
[Finished in 2.1s with exit code 1]
Kindly help me solve this problem
Thanks