我有一个 C++ 类,它被引用,然后我要声明一个变量。我在objective-c中声明:
cObject obj = cObject();
obj.myFunct("test");
但似乎存在链接器错误。它说:
Undefined symbols for architecture armv7:
"cObject::cObject()", referenced from:
-[...] in xxx.o
___cxxx_global_var_init in xxx.o
"cObject::myFunct(std::__1:basic_string<char,str::__1::char_traits<char>, str::__1::allocator<char> >)", referenced from:
-[///] in xxx.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1(use -v to see invocation)
编辑:评论中解决的第一个错误:不要定义一个空的构造函数解决了第一部分。第二部分是指调用 obj.myFunct("test");