Linking error will using SimpleAudioEngine in HelloWorld project of cocos2dx-2.1.0-wp8-2.0-alpha

Linking error will using SimpleAudioEngine in HelloWorld project of cocos2dx-2.1.0-wp8-2.0-alpha
0.0 0


I downloaded cocos2dx-2.1.0-wp8-2.0-alpha from the site and deployed successfully the Helloworld project present in it. But when I added the Simple AudioEngine in it to play the backgroundmusic I got the following linking error.

error LNK1120: 2 unresolved externals C:2dx-2.1.0-wp8-2.0-alpha\ARM\Debug\HelloWorld\HelloWorld.exe

error LNK2019: unresolved external symbol “*declspec public: static class CocosDenshion::SimpleAudioEngine **cdecl CocosDenshion::SimpleAudioEngine::sharedEngine(void)” (_imp?sharedEngine@SimpleAudioEngine@CocosDenshion@SAPAV12XZ) referenced in function “public: virtual bool *cdecl HelloWorld::init" C:2dx-2.1.0-wp8-2.0-alpha\HelloWorld\HelloWorldScene.obj
error LNK2019: unresolved external symbol "*declspec(dllimport) public: void cdecl CocosDenshion::SimpleAudioEngine::playBackgroundMusic" referenced in function "public: virtual boolcdecl HelloWorld::init(void)” (?init@HelloWorld@@UAA_NXZ) C:2dx-2.1.0-wp8-2.0-alpha\HelloWorld\HelloWorldScene.obj HelloWorld

I am just posting a cpp file. I know that it is not able to link with SimpleAudioEngine. So what is the way to include the SimpleAudioEngine (1.4 KB)


Looks like the CocosDenshion .lib isn’t getting linked correctly?

Make sure the lib is being generated correctly when building the CocosDenshion project and that the resulting file and its directory are getting pointed at by your project settings for the configuration you’re using.


For reference, the .lib should be getting put in $(SolutionDir)$(Platform)(Configuration)(MSBuildProjectName)
An example of which would be:
This directory already appears to be listed in HelloWorld’s ‘additional library directories’ as ‘…(Platform)(Configuration)’ and the lib is referenced in the HelloWorld’s ‘additional dependencies as ’Cocos2dWindowsPhone.lib’ so it shouldn’t have any problems out of the box.

Also, HelloWorld’s ‘additional include directories’ already includes ‘…/CocosDenshionWindowsPhone/include’ so you should be fine for headers.


Hmm… if I’m not mistaken the preprocessor directives for CocosDenshion should include CC_EXPORT_WINDOWS to make the CC_DLL macro equate to export when building the lib. Currently rebuilding with it added in to test the theory…


Oh wait, it was right in front of me - I posted it just a second ago.

“the lib is referenced in the HelloWorld’s ‘additional dependencies’ as ‘Cocos2dWindowsPhone.lib’” - that’s the reference to the main Cocos2D-X library, not Denshion. Denshion isn’t listed.

So you need to add ‘CocosDenshionWindowsPhone.lib;’ to your ‘Project > Properties > Configuration Properties > Linker > Input > Additional Dependencies’ line.


It worked and now that linking error never comes. The file is present in the assets folder with correct spelling.But now it has started throwing an exception when I call this method


Have you tried it out it in the sample project of the cocos2dx-2.1.0-wp8-2.0-alpha.

I would be something ridiculous if the have launched alpha with this bug intact. :frowning:


Did you found the way around that exception ?? I am stuck at the same exception.


Muhammad Wajahat wrote:

Did you found the way around that exception ?? I am stuck at the same exception.

Please try to provide fullpath by using,

const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(sound.wav);

This should work, remember only use .wav file formats as they are supported only for this version of cocos2dx for windows phone8 branch


i will port my game in wp8 but in game some sound file(.wav) play fine
but some file sound(.wav) throw exception.

exception:-First-chance exception at 0x77C41EDB in TaskHost.exe: Microsoft C++ exception: Platform::FailureException ^ at memory location 0x0117EEB0. HRESULT:0x80004005

If there is a handler for this exception, the program may be safely continued.


Could you wrap it in a catchall?

   // ... your code
catch(const std::exception& ex)
   std::cout << ex.what() << std::endl;
   std::cout << "You have got an exception,"
                "better find out its type and add appropriate handler"
                "like for std::exception above to get the error message!" << std::endl;