Symbol(s) not found

Discussion in 'iOS Programming' started by Limb, Aug 17, 2008.

  1. Limb macrumors member

    Aug 30, 2007
    Hello all,

    Having a bit of trouble here, trying to take the GLSprite texture loading code and transform it into a class, but im getting some strange build errors (Symbol(s) not found) that I can't figure out why I'm getting. Would appreciate it if anyone could take a look at it and tell me what I'm doing wrong, as my searches so far have turned up nothing.

    Code and errors are as follows:

    #import <UIKit/UIKit.h>
    #import <OpenGLES/EAGL.h>
    #import <OpenGLES/ES1/gl.h>
    #import <OpenGLES/ES1/glext.h>
    @interface Texture : NSObject {
    	GLuint spriteTexture;
    - (GLuint) initWithImage:(NSString *)image;
    #import <QuartzCore/QuartzCore.h>
    #import <OpenGLES/EAGLDrawable.h>
    #import "Texture.h"
    @implementation Texture
    - (GLuint)initWithImage:(NSString *) Image
    	CGImageRef spriteImage;
    	CGContextRef spriteContext;
    	GLubyte *spriteData;
    	size_t	width, height;
    	// Creates a Core Graphics image from an image file
    	spriteImage = [UIImage imageNamed:Image].CGImage;
    	// Get the width and height of the image
    	width = CGImageGetWidth(spriteImage);
    	height = CGImageGetHeight(spriteImage);
    	// Texture dimensions must be a power of 2. If you write an application that allows users to supply an image,
    	// you'll want to add code that checks the dimensions and takes appropriate action if they are not a power of 2.
    	if(spriteImage) {
    		// Allocated memory needed for the bitmap context
    		spriteData = (GLubyte *) malloc(width * height * 4);
    		// Uses the bitmatp creation function provided by the Core Graphics framework. 
    		spriteContext = CGBitmapContextCreate(spriteData, width, height, 8, width * 4, CGImageGetColorSpace(spriteImage), kCGImageAlphaPremultipliedLast);
    		// After you create the context, you can draw the sprite image to the context.
    		CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), spriteImage);
    		// You don't need the context at this point, so you need to release it to avoid memory leaks.
    		// Use OpenGL ES to generate a name for the texture.
    		glGenTextures(1, &spriteTexture);
    		// Bind the texture name. 
    		glBindTexture(GL_TEXTURE_2D, spriteTexture);
    		// Speidfy a 2D texture image, provideing the a pointer to the image data in memory
    		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, spriteData);
    		// Release the image data
    		// Set the texture parameters to use a minifying filter and a linear filer (weighted average)
    		// Enable use of the texture
    		// Set a blending function to use
    		glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    		// Enable blending
    		return spriteTexture;
    Error Output:
    Undefined symbols:
      "_CGContextRelease", referenced from:
          -[Texture initWithImage:] in Texture.o
      "_CGContextDrawImage", referenced from:
          -[Texture initWithImage:] in Texture.o
      "_CGBitmapContextCreate", referenced from:
          -[Texture initWithImage:] in Texture.o
      "_CGImageGetColorSpace", referenced from:
          -[Texture initWithImage:] in Texture.o
      "_CGImageGetWidth", referenced from:
          -[Texture initWithImage:] in Texture.o
      "_CGImageGetHeight", referenced from:
          -[Texture initWithImage:] in Texture.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    Again, any help would be greatly appreciated.
  2. ayasin macrumors 6502

    Jun 26, 2008
    You're missing a library reference. You need to add the openGL libraries to your project.
  3. kainjow Moderator emeritus


    Jun 15, 2000
    Those symbols are Quartz symbols. Make sure you've linked in the QuartzCore/Quartz frameworks (which should be from UIKit). It is strange.
  4. Limb thread starter macrumors member

    Aug 30, 2007
    Turned out I didn't have the CoreGraphics framework included. Thanks for the suggestions, as they made me realize i should check which frameworks were in GLSprite that I didn't have.


Share This Page