それで、iPhone 用のエンジンを開発しました。このエンジンを使って、いくつかの異なるゲームを作成したいと思います。エンジンのファイルを各ゲームのプロジェクト ディレクトリ内にコピー アンド ペーストするのではなく、各ゲームからエンジンにリンクする方法を考えました。少し調べてみたところ、iPhone でこれを行うには静的ライブラリが最適な方法のようです。
Skeleton という新しいプロジェクトを作成し、すべてのエンジン ファイルをそこにコピーしました。このガイドを使用して静的ライブラリを作成し、そのライブラリを Chooser というプロジェクトにインポートしました。しかし、プロジェクトをコンパイルしようとすると、ControlScene.mm というファイルに含まれているいくつかの C++ データ構造について、Xcode が不平を言い始めました。ここに私のビルドエラーがあります:
"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
これらの問題が発生している理由について誰かが洞察を提供できれば、私はそれを感謝します.