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.
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:
Cocos2dx-2.1.0-wp8-2.0-alpha\Win32\Debug\CocosDenshionWindowsPhone
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
hi,
i will port my game in wp8 but in game some sound file(.wav) play fine
but some file sound(.wav) throw exception.
code:-CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(std::string(name).c_str());
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.
try
{
// ... your code
}
catch(const std::exception& ex)
{
std::cout << ex.what() << std::endl;
}
catch(...)
{
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;
}