我收到一个我无法解决的错误。
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");
我的构建设置:
我是否必须在我的 iOS 类(std)中定义某种命名空间?