gpt4 book ai didi

iphone - 体系结构 i386 的 undefined symbol ,ld : symbol(s) not found for architecture i386

转载 作者:行者123 更新时间:2023-12-03 19:18:09 27 4
gpt4 key购买 nike

我想我又遇到了障碍,事情是这样的:

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

我正在尝试在 Xcode 4.3.2 上的 iPhone 5.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() {}
};

最佳答案

编译器未找到您的 IRenderingEngine 实现。要么缺少实现,要么文件未正确添加到目标。

关于iphone - 体系结构 i386 的 undefined symbol ,ld : symbol(s) not found for architecture i386,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12137882/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com