cocos2dx as shared library

Hello, everybody!

Why cocos2d is made as shared library in Bada projects? Is it possible to make it as static library (like Box2d)? I tried to do so for Bada 1.2, but my app crashes just after applicationDidFinishLaunching (function successfully complete, but CCApplication::OnTimerExpired is never run).

PS: With cocos2dx as shared library the app works well

Thanks a lot!

Hello!

Done. For bada 1.0. At this case all cocos2d shared and static libraries should be linked with app project - you have no ability to link something with static libraries.

Now some words why I did so.
Situation: Bada IDE 1.2.1. My game should run on Bada 1.2 device. I created a set of classes which extends cocos2d functionality. I have
class MyNodeRGBA : public cocos2d::CCNode, public cocos2d::CCRGBAProtocol
I run CCFadeOut action on it. And in CCFadeOut::update(ccTime time)

CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(m_pTarget)

returns NULL! Why??? I call the same dynamic_cast in my app - ok. I add my class into cocos2dx library - ok. So it is compiler problem (in bada 2.0 project made on Bada IDE 2.0.3 all runs without problems). The most simple way to resolve the problem is to make cocos2dx as static library in cocos2dx bada 1.0 project

Ah…, this is the same issue which on android platform. It’s the bug of gcc compiler. We have used static libraries on android now, and the bug can be resolved by this way. I will test it on bada. If it does exist, we will consider to build cocos2dx as a static library. Thanks for your feedback.

Alexander Trutchenko wrote:

Hello!
>
Done. For bada 1.0. At this case all cocos2d shared and static libraries should be linked with app project - you have no ability to link something with static libraries.
>
Now some words why I did so.
Situation: Bada IDE 1.2.1. My game should run on Bada 1.2 device. I created a set of classes which extends cocos2d functionality. I have
class MyNodeRGBA : public cocos2d::CCNode, public cocos2d::CCRGBAProtocol
I run CCFadeOut action on it. And in CCFadeOut::update(ccTime time)
>
CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(m_pTarget)
>
returns NULL! Why??? I call the same dynamic_cast in my app - ok. I add my class into cocos2dx library - ok. So it is compiler problem (in bada 2.0 project made on Bada IDE 2.0.3 all runs without problems). The most simple way to resolve the problem is to make cocos2dx as static library in cocos2dx bada 1.0 project

Hi, Alexander Trutchenko,
We have make cocos2dx to a static library, and now it works fine on bada 1.* devices. You can test it by pull the latest code on the github,https://github.com/cocos2d/cocos2d-x.

Hi, James Chen,

Thanks a lot! It is really helps users to avoid problems making their cocos2dx extensions under Bada 1.x projects.

I have same problem on iOS platform… :frowning:

How do I fix it?

pSelectorTarget has 1 for m_uReference value, but receive BAD ACCESS on CCObject::retain function like picture.

Hi, Jihyun,
We use source code to build projects on ios platform. And we haven’t found this issue. Could you please paste more codes to let us analyse? Thanks.
Jihyun Choi wrote:

I have same problem on iOS platform… :frowning:
>
How do I fix it?
>
pSelectorTarget has 1 for m_uReference value, but receive BAD ACCESS on CCObject::retain function like picture.

James. I already post the problem but nobody answerd… :blush:

I used CCCallFuncND::actionWithTarget(actionFactory, callfuncND_selector(ActionFactory::callbackSoundAction), ap); method, and actionFactory(first argument) is singleton.

click link please…

http://www.cocos2d-x.org/boards/6/topics/8795

thank you :slight_smile:

Hi, Jihyun Choi

It seems, it is another problem.

  1. Did you create cocos2dx as shared library on iOS? Because there is no issue when we use cocos2dx as static library.
  2. I looked at the linked issue. It looks like a problem with reference counting in action factory. Please trace your action factory reference counter and determine when and where it changes.

I agree with Alexander Trutchenko. :slight_smile:

Hi Alexander and James, Thanks to reply. :slight_smile:

I inclueded all source codes of cocos2dx, isn’t it static library ?

and reference count is changed at CCObejct::retain

at that time CCObject is NULL at there.

It seams dynamic_cast was fail…

Can you advice more? thank you very much.!

Hi, I think this bug has been resolved in the latest release.

Jihyun Choi wrote:

Hi Alexander and James, Thanks to reply. :slight_smile:
>
I inclueded all source codes of cocos2dx, isn’t it static library ?
>
and reference count is changed at CCObejct::retain
>
at that time CCObject is NULL at there.
>
It seams dynamic_cast was fail…
>
Can you advice more? thank you very much.!