|
|
Xcode : Library problem
|
|
|
|
Dedicated MacNNer
Join Date: Mar 2002
Status:
Offline
|
|
Hi,
I'm attempting to compile this code from nehe:
Code:
//
// This code was created by Jeff Molofee '99
//
// If you've found this code useful, please let me know.
//
// Visit me at www.demonews.com/hosted/nehe
//
/**************************************************************/
// This code was ported to MacOS by Tony Parker.
// I'd also appreciate it if you could drop me a line if you found
// this code useful.
//
// Tony Parker - [email protected]
//
// Have a nice day.
#include <stdio.h> // Header File For Standard Input / Output
#include <stdarg.h> // Header File For Variable Argument Routines
#include <string.h> // Header File For String Management
#include <stdlib.h>
#include <OPENGL/gl.h> // Header File For The OpenGL32 Library
#include <OPENGL/glu.h> // Header File For The GLu32 Library
#include <GLUT/glut.h> // Header File For The GLUT Library
#include <math.h>
// Constants -----------------------------------------------------------------
#define kWindowWidth 400
#define kWindowHeight 300
// Function Prototypes -------------------------------------------------------
GLvoid InitGL(GLvoid);
GLvoid DrawGLScene(GLvoid);
GLvoid ReSizeGLScene(int Width, int Height);
// Main ----------------------------------------------------------------------
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (kWindowWidth, kWindowHeight);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
InitGL();
glutDisplayFunc(DrawGLScene);
glutReshapeFunc(ReSizeGLScene);
glutMainLoop();
return 0;
}
// Init ----------------------------------------------------------------------
GLvoid InitGL(GLvoid)
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black
glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LESS); // The Type Of Depth Test To Do
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // Reset The Projection Matrix
gluPerspective(45.0f,(GLfloat)kWindowWidth/(GLfloat)kWindowHeight,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window
glMatrixMode(GL_MODELVIEW);
}
// DrawGLScene ---------------------------------------------------------------
GLvoid DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View
glTranslatef(-1.5f,0.0f,-6.0f);
glBegin(GL_POLYGON);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();
glTranslatef(3.0f,0.0f,0.0f);
glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();
glFlush();
}
// ReSizeGLScene ------------------------------------------------------------
GLvoid ReSizeGLScene(int Width, int Height)
{
glViewport (0, 0, (GLsizei) Width, (GLsizei) Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (GLfloat) Width / (GLfloat) Height, 0.1, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
I updated the libraries with their correct paths
#include <OPENGL/gl.h>
#include <OPENGL/glu.h>
#include <GLUT/glut.h>
The code compiles and links but upon executing it fails with
Code:
asddd has exited due to signal 6 (SIGABRT).
[Session started at 2006-08-01 23:01:04 +0100.]
ZeroLink: unknown symbol '_glutInit'
I suspect the problem is with the glut.h framework, any suggestions? Thanks in advance.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 2004
Location: Downtown Austin, TX
Status:
Offline
|
|
You included the OpenGL framework right?
And if I remember correctly, you don't need to include GLUT (it's been a while since I've dabbled in OpenGL).
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Aug 2005
Status:
Offline
|
|
Originally Posted by DevNine
Hi,
The code compiles and links but upon executing it fails with
Code:
asddd has exited due to signal 6 (SIGABRT).
[Session started at 2006-08-01 23:01:04 +0100.]
ZeroLink: unknown symbol '_glutInit'
The code doesn't link. Turn off ZeroLink and you'll get a link error when you build the project.
Make sure you added the GLUT framework to your project. If you did add the GLUT framework, try adding the Cocoa framework to your project. GLUT is written in Cocoa. I'm not sure what version of Mac OS X you're using, but some older versions required you to add the Cocoa framework to build GLUT applications. I don' use GLUT so I'm not sure if you still need to add the Cocoa framework, but it's something to try.
If you still can't get the code to build, take a look at SDL. It is a cross-platform game library that does everything GLUT does. If you click the link in my URL you can read an article I wrote on using SDL with OpenGL. The article includes a simple program that creates a window and draws a colored rectangle in the window. You could take the OpenGL code from the NeHe tutorial and add it to my program, making sure not to add the GLUT code.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|