gpt4 book ai didi

c++ - undefined symbol ,在 iOS 中使用 C++

转载 作者:行者123 更新时间:2023-11-28 08:04:02 24 4
gpt4 key购买 nike

我收到无法解决的错误。

Undefined symbols for architecture i386:  
"ObjSurface::ObjSurface(std::string const&)", referenced from:
-[RootViewController testObj] in RootViewController.o ld:
symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

对象表面.hpp

#include "Interfaces.hpp"

class ObjSurface : public ISurface {
public:
ObjSurface(const string &name);
int GetVertexCount() const;
int GetLineIndexCount() const { return 0; }
int GetTriangleIndexCount() const;
void GenerateVertices(vector<float>& vertices, unsigned char flags) const;
void GenerateLineIndices(vector<unsigned short>& indices) const {}
void GenerateTriangleIndices(vector<unsigned short>& indices) const;
private:
string m_name;
vector<ivec3> m_faces;
mutable size_t m_faceCount;
mutable size_t m_vertexCount;
static const int MaxLineSize = 128;
};

对象表面.cpp

ObjSurface::ObjSurface(const string &name) :
m_name(name),
m_faceCount(0),
m_vertexCount(0)
{
m_faces.resize(GetTriangleIndexCount() / 3);
ifstream objFile(m_name.c_str());
vector<ivec3>::iterator face = m_faces.begin();
while (objFile) {
char c = objFile.get();
if (c == 'f') {
assert(face != m_faces.end() && "parse error");
objFile >> face->x >> face->y >> face->z;
*face++ -= ivec3(1, 1, 1);
}
objFile.ignore(MaxLineSize, '\n');
}
assert(face == m_faces.end() && "parse error");
}

ViewController.mm中的用法:

#include "ObjSurface.hpp"
surfaces[0] = new ObjSurface(path + "/Ninja.obj");

我的build设置:

enter image description here

我是否必须在我的 iOS 类 (std) 中定义某种命名空间?

最佳答案

ObjSurface.cpp 是否真的被编译和链接?即它在“编译源代码”构建阶段?听起来好像不是。

关于c++ - undefined symbol ,在 iOS 中使用 C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10675223/

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