所以我为 iPhone 开发了一个引擎,我想用它来构建几个不同的游戏。与其在每个游戏的项目目录中复制和粘贴引擎的文件,我还需要一种从每个游戏链接到引擎的方法,所以如果我需要对其进行更改,我只需要这样做一次。经过一番折腾,似乎静态库是在 iPhone 上执行此操作的最佳方式。
我创建了一个名为 Skeleton 的新项目,并将我的所有引擎文件复制到其中。我使用本指南创建了一个静态库,并将该库导入到一个名为 Chooser 的项目中。但是,当我尝试编译该项目时,Xcode 开始抱怨我包含在一个名为 ControlScene.mm 的文件中的一些 C++ 数据结构。这是我的构建错误:
"operator delete(void*)", referenced from:
-[ControlScene dealloc] in libSkeleton.a(ControlScene.o)
-[ControlScene init] in libSkeleton.a(ControlScene.o)
__gnu_cxx::new_allocator<operation_t>::deallocate(operation_t*, unsigned long)in libSkeleton.a(ControlScene.o)
__gnu_cxx::new_allocator<operation_t*>::deallocate(operation_t**, unsigned long)in libSkeleton.a(ControlScene.o)
"operator new(unsigned long)", referenced from:
-[ControlScene init] in libSkeleton.a(ControlScene.o)
__gnu_cxx::new_allocator<operation_t*>::allocate(unsigned long, void const*)in libSkeleton.a(ControlScene.o)
__gnu_cxx::new_allocator<operation_t>::allocate(unsigned long, void const*)in libSkeleton.a(ControlScene.o)
"std::__throw_bad_alloc()", referenced from:
__gnu_cxx::new_allocator<operation_t*>::allocate(unsigned long, void const*)in libSkeleton.a(ControlScene.o)
__gnu_cxx::new_allocator<operation_t>::allocate(unsigned long, void const*)in libSkeleton.a(ControlScene.o)
"___cxa_rethrow", referenced from:
std::_Deque_base<operation_t, std::allocator<operation_t> >::_M_create_nodes(operation_t**, operation_t**)in libSkeleton.a(ControlScene.o)
std::_Deque_base<operation_t, std::allocator<operation_t> >::_M_initialize_map(unsigned long)in libSkeleton.a(ControlScene.o)
"___cxa_end_catch", referenced from:
std::_Deque_base<operation_t, std::allocator<operation_t> >::_M_create_nodes(operation_t**, operation_t**)in libSkeleton.a(ControlScene.o)
std::_Deque_base<operation_t, std::allocator<operation_t> >::_M_initialize_map(unsigned long)in libSkeleton.a(ControlScene.o)
"___gxx_personality_v0", referenced from:
___gxx_personality_v0$non_lazy_ptr in libSkeleton.a(ControlScene.o)
___gxx_personality_v0$non_lazy_ptr in libSkeleton.a(MenuLayer.o)
"___cxa_begin_catch", referenced from:
std::_Deque_base<operation_t, std::allocator<operation_t> >::_M_create_nodes(operation_t**, operation_t**)in libSkeleton.a(ControlScene.o)
std::_Deque_base<operation_t, std::allocator<operation_t> >::_M_initialize_map(unsigned long)in libSkeleton.a(ControlScene.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
如果有人可以就为什么会出现这些问题提供一些见解,我将不胜感激。