dynamic_cast across shared libraries

I defined a KeyPadDelegate

class CPKeyPadDispatcher : public cocos2d::CCObject, public cocos2d::CCKeypadDelegate {

and then

g_keypad_dispatcher = new CPKeyPadDispatcher();
if(g_keypad_dispatcher) {                  
    cocos2d::CCKeypadDispatcher::sharedDispatcher()->addDelegate(g_keypad_dispatcher);
}

it is OK on win32, but crashed on android. I found it because dynamic_cast results a NULL pointer in

bool CCKeypadHandler::initWithDelegate(CCKeypadDelegate *pDelegate)
{
    CCAssert(pDelegate != NULL, "It's a wrong delegate!");    
    m_pDelegate = pDelegate;
    dynamic_cast(pDelegate)->retain();

    return true;
}

I googled and it’s said that dynamic_cast does not work across shared libs. I not familiar with that, what’s the best/simplest way to fix this?

reference:
* http://blog.sina.com.cn/s/blog_48ebca64010005ju.html

version 0.12 build cocos2dx as a static lib.
So you should use it.

CCTouchHandler has fixed this problem, so CCKeypadHandler should follow the same appoach?