Reputation: 2542
I'm building a game with cocos2d-x for iOS 6/7 (Using Xcode 5 and iOS SDK 7.0), and started introducing some patterns that exploit inheritance, and I ran into this exception.
libc++abi.dylib`vtable for __cxxabiv1::__si_class_type_info:
0x284a540: addb %al, (%eax)
0x284a542: addb %al, (%eax)
0x284a544: jo 0x284a4eb ; vtable for __cxxabiv1::__libcxxabi::__void + 91
0x284a546: testb (%edx), %al
0x284a548: lesl 2(%edx,%eax,4), %ebx
0x284a54c: movl $2046984796, %edx
0x284a551: popl %esp
The code looks this:
for (auto enemyItr = EnemyQueue::getEnemyContainer().begin(); enemyItr != EnemyQueue::getEnemyContainer().end(); ++enemyItr)
{
EnemyCharacter *enemyCharacter = dynamic_cast<EnemyCharacter*>(*enemyItr);
CCSprite *enemy = enemyCharacter->getCharacterSprite(); // inhertiance introduced to EnemyCharacter class
CCRect enemyMeleeRect = enemy->boundingBox(); //-> exception
}
I thought this is a linker error, and tried including libstdc++ "Link Binary with Libraries". I also tried including "-lstdc++" in Other Linker flags as well, but the exception persists.
Is there anyway around this?
Upvotes: 2
Views: 2033
Reputation: 4306
I had the same error, adding libstdc++.dylib
from Build Phases -> Link Binary With Libraries
resolved the error. Hope it will help others coming to this question.
Upvotes: 1
Reputation: 2542
I believe the reason was due to the use of C style callbacks in the cocos2d x framework. I had made these functions virtual, and hoping to override them in derived classes. But, that causes this exception. I guess I have to find a workaround or just forget about using OOP.
Upvotes: 0