1

Xcode build prints this error .

Undefined symbols:
"EGViewportDimensionMake(unsigned int, unsigned int, unsigned int, unsigned int)", referenced from: -[Renderer render] in Renderer.o ld: symbol(s) not found collect2: ld returned 1 exit status

I cannot figure out what's the problem. I'm not good at classic C syntax. These are the function source code files:

EGViewportDimension.h

#import <Foundation/Foundation.h>

struct EGViewportDimension
{
    NSUInteger x;
    NSUInteger y;
    NSUInteger width;
    NSUInteger height;
};
typedef struct EGViewportDimension EGViewportDimension;

EGViewportDimension EGViewportDimensionMake(NSUInteger x, NSUInteger y, NSUInteger width, NSUInteger height);

EGViewportDimension.m

#import "EGViewportDimension.h"

EGViewportDimension EGViewportDimensionMake(NSUInteger x, NSUInteger y, NSUInteger width, NSUInteger height)
{
    EGViewportDimension dim;
    dim.x = x;
    dim.y = y;
    dim.width = width;
    dim.height = height;
    return dim;
}

I referenced and used this like:

Renderer.mm

#import "EGViewportDimension.h"

//.... many codes omitted.

EGViewportDimension vdim = EGViewportDimensionMake(0, 0, backingWidth, backingHeight);
Paul R
  • 208,748
  • 37
  • 389
  • 560
eonil
  • 83,476
  • 81
  • 317
  • 516
  • 1
    Thanks for clarifying. Did you make sure EGViewPortDimension.m is included in the build(or compile) folder of the target? – Johannes Rudolph Feb 06 '10 at 15:35
  • I checked it right now in project tree. And it's exist at here. Targets > app3 > Compile Sources (17) > EGViewportDimention.m – eonil Feb 06 '10 at 15:42

2 Answers2

0

This is not a compiler but a linker issue. You referenced this method from [Renderer render], however the linker is unable to find it. Did you check you have included EGViewportDimension.h at the appropriate place (eg. Renderer.m)?

Johannes Rudolph
  • 35,298
  • 14
  • 114
  • 172
  • Yes, I added the code fragment of Renderer.mm to question. I'm guessing I used some wrong C syntax. But I can't figure it out. – eonil Feb 06 '10 at 15:34
0

I solved it by renaming Renderer.mm to Renderer.m. It was used some C++ classes so I made it as Objective-C++ code, but there was some problem. I removed all C++ calls and renamed it to Objective-C code.

But I still don't know what's the problem with Objective-C++ with classic C function definition.

----(edit)----

I asked this as another question, and I got an answer. See here: Does it prohibited calling classic C function from Objective-C++ class method body?

Community
  • 1
  • 1
eonil
  • 83,476
  • 81
  • 317
  • 516