Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
565 views
in Technique[技术] by (71.8m points)

ios - How to pass id<MTLDevice> in objectiveC++

I am very new to Objective C world please bear with me. I am working on some iOS metal project using xCode. I am getting some strange linking error during compilation.

Defined as

class MetalDevice { public: MetalDevice(); std::shared_ptr createQueueForOperation(GPU_OPERATIONS gpuOperations); private: id _device; };

And it's corresponding objeciveC++ (.mm) file is

MetalDevice::MetalDevice() {
    _device = MTLCreateSystemDefaultDevice();
}

std::shared_ptr<GPUQueue> MetalDevice::createQueueForOperation(GPU_OPERATIONS gpuOperations) {
    return std::dynamic_pointer_cast<GPUQueue>(std::make_shared<MetalQueue>(_device));
}

My MetalQueue file is expecting MetalDevice as a parameter

class MetalQueue: public GPUQueue { public: ~MetalQueue() {} MetalQueue(id device){} };

I am getting following linking error U

undefined symbols for architecture arm64: "vtable for metalCPP::MetalQueue", referenced from: metalCPP::MetalQueue::MetalQueue(id) in MetalDevice.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Can someone please help me how to resolve this error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...