Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Xcode : Library problem

Xcode : Library problem
Thread Tools
DevNine
Dedicated MacNNer
Join Date: Mar 2002
Status: Offline
Reply With Quote
Aug 1, 2006, 06:01 PM
 
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.
http://winlab.csbnet.se Visit the Mac Demo Scene.
     
jamil5454
Mac Elite
Join Date: Oct 2004
Location: Downtown Austin, TX
Status: Offline
Reply With Quote
Aug 2, 2006, 10:43 AM
 
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).
     
szymczyk
Fresh-Faced Recruit
Join Date: Aug 2005
Status: Offline
Reply With Quote
Aug 2, 2006, 03:06 PM
 
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.
Mark Szymczyk
Author, Xcode Tools Sensei
http://www.meandmark.com
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:31 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,