我在xcode項目中使用了一個cpp文件。在cpp文件我做了以下在cpp中聲明的gloabal變量在目標c中使用
ReadYML.h
typedef struct {
float Position[3];
float Color[4];
float TexCoord[2];
} Vertex_OR;
extern Vertex_OR Vertices_OR [100];
extern GLubyte Indices_OR [30];
在ReadYML.cpp
我賦值這一點。
在view.m
我宣佈 「sample.h」
,並試圖訪問Vertices_OR和Indices_OR但我得到下面的錯誤?
Undefined symbols for architecture i386:
"_Indices_OR", referenced from:
loadyml() in ReadYMLfile.o
"_Vertices_OR", referenced from:
loadyml() in ReadYMLfile.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
這裏有什麼問題?我需要使用在「Sample.h」中聲明的全局變量來訪問view.m?可能嗎?
'出現view.m'未包含在此鏈接器錯誤中;而是它看起來像'ReadYMLFile.o'。 – trojanfoe 2013-03-07 16:22:09