0

I'm new to c++ and I'm having some trouble with making a header file. The exact error I'm getting is

obj.obj : error LNK2019: unresolved external symbol "float * __cdecl getVertices(class std::basic_string,class std::allocator >,int,float *)" (?getVertices@@YAPAMV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HPAM@Z) referenced in function "struct ObjModel __cdecl importObj(void)" (?importObj@@YA?AUObjModel@@XZ)

The bugs/solutions I'm seeing seem much more complicated that what I'm doing. Here's my header, which I suspect is wrong.

//obj.h
#ifndef OBJ_H_INCLUDED
#define OBJ_H_INCLUDED

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <iostream>
using namespace std;

struct ObjVertex {
     float x, y, z;
};

struct ObjTriangle {
     int Vertex[3];
     int Normal[3];
};


struct ObjModel {
     int NumVertex, NumNormal, NumTexCoord, NumTriangle;
     ObjVertex *VertexArray;
     ObjVertex *NormalArray;
     ObjTriangle *TriangleArray;
};

//function prototypes
float* getVertices(string buf, int i, float* ret);
ObjModel importObj();
char* subString(char* buf, int b, int e);

#endif

I've just started in C++ but I have experience in Java and C, so it's probably an issue with me not knowing some C++ specific thing.

4

2 回答 2

3

没有实现,float* getVertices(string buf, int i, float* ret);因此您会收到链接器错误。

于 2012-04-17T17:45:40.817 回答
2

您必须将getVertices声明的模块附加到项目中。

于 2012-04-17T20:02:35.640 回答