4

私は再び障害にぶつかったと思います、これが取引です:

Undefined symbols for architecture i386:
  "CreateRenderer1()", referenced from:
      -[GLView initWithFrame:] in GLView.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

質問したときに自動検索に表示されるほぼすべての提案を試しました。

これらのライブラリを「ビルドフェーズ」の下の「ライブラリとバイナリをリンク」タブに追加します。

OpenGLES.framework
QuartzCore.framework

関連するすべてのファイルをターゲット/コンパイル済みソースに追加する

拡張子が.mのすべての関連ファイルの名前を.mmに変更

これをXcode4.3.2のiPhone5.1シミュレーターでコンパイルしようとしていますが、欠けていることが明白なものはありますか?設定に何かあるような気がしますが、試したことは何も機能していないようです=(

編集:

GLView.h:

#import "IRenderingEngine.hpp"
#import <OpenGLES/EAGL.h>
#import <QuartzCore/QuartzCore.h>

@interface GLView : UIView {
    EAGLContext* m_context;
    IRenderingEngine* m_renderingEngine;
    float m_timestamp;
}

- (void) drawView: (CADisplayLink*) displayLink;
- (void) didRotate: (NSNotification*) notification;

@end

GLView.mm:

#import <OpenGLES/EAGLDrawable.h>   
#import "GLView.h"
#import "mach/mach_time.h"
#import <OpenGLES/ES2/gl.h> // <-- for GL_RENDERBUFFER only

@implementation GLView

+ (Class) layerClass
{
    return [CAEAGLLayer class];
}

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        CAEAGLLayer* eaglLayer = (CAEAGLLayer*) super.layer;
        eaglLayer.opaque = YES;
        m_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];

        if (!m_context || ![EAGLContext setCurrentContext:m_context]) {
            [self release];
            return nil;
        }

        m_renderingEngine = CreateRenderer1();

        [m_context
         renderbufferStorage:GL_RENDERBUFFER
         fromDrawable: eaglLayer];

        m_renderingEngine->Initialize(CGRectGetWidth(frame), CGRectGetHeight(frame));

        [self drawView: nil];
        m_timestamp = CACurrentMediaTime();

        CADisplayLink* displayLink;
        displayLink = [CADisplayLink displayLinkWithTarget:self
                                                  selector:@selector(drawView:)];

        [displayLink addToRunLoop:[NSRunLoop currentRunLoop]
                          forMode:NSDefaultRunLoopMode];

        [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

        [[NSNotificationCenter defaultCenter]
         addObserver:self
         selector:@selector(didRotate:)
         name:UIDeviceOrientationDidChangeNotification
         object:nil];
    }
    return self;
}


- (void) didRotate: (NSNotification*) notification
{
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    m_renderingEngine->OnRotate((DeviceOrientation) orientation);
    [self drawView: nil];
}

- (void) drawView: (CADisplayLink*) displayLink
{
    if (displayLink != nil) {
        float elapsedSeconds = displayLink.timestamp - m_timestamp;
        m_timestamp = displayLink.timestamp;
        m_renderingEngine->UpdateAnimation(elapsedSeconds);
    }

    m_renderingEngine->Render();
    [m_context presentRenderbuffer:GL_RENDERBUFFER];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end

IRenderingEngine.hpp

enum DeviceOrientation {
    DeviceOrientationUnknown,
    DeviceOrientationPortrait,
    DeviceOrientationPortraitUpsideDown,
    DeviceOrientationLandscapeLeft,
    DeviceOrientationLandscapeRight,
    DeviceOrientationFaceUp,
    DeviceOrientationFaceDown,
};

// Creates an instance of the renderer and sets up various OpenGL state.
struct IRenderingEngine* CreateRenderer1();

// Interface to the OpenGL ES renderer; consumed by GLView.
struct IRenderingEngine {
    virtual void Initialize(int width, int height) = 0;    
    virtual void Render() const = 0;
    virtual void UpdateAnimation(float timeStep) = 0;
    virtual void OnRotate(DeviceOrientation newOrientation) = 0;
    virtual ~IRenderingEngine() {}
};
4

2 に答える 2

2

IRenderingEngine の実装がコンパイラによって検出されていません。実装が欠落しているか、ファイルがターゲットに正しく追加されていません。

于 2012-08-27T07:54:52.317 に答える
0

私はそれを修正しましたが、ファイルがどのように「削除」されたかを本当に理解することはできませんでした。今日、私は答えを見つけました。

Finderでサブフォルダの名前を手動で変更した場合でも、XCodeは古いパスパスを指しますが、これは現在無効です。

これを修正するために、無効なグループフォルダーを右クリックし、右側を調べたファイルで、パスを手動で再度設定できるあいまいな小さなボックスをクリックしました。

于 2012-09-06T11:29:18.877 に答える