Run cocos2d-x project in browser

I have done some research and can’t find a direct easy way to run my cocos2d-x project which is built in c++ on the web. If anyone has a solution besides re-writing my code in js or html I would love to hear it. Things I have tried so far…

Emscripten : I was able to convert cpp/c files in js and run them using this, but I would like an easy way to run a whole project, rather than individual class files. Cocos2d has iffy support using Emscripten and there isn’t great documentation to get this to work. If anyone has success with this, please guide me.

Marmalade : It looks like this can be done with cocos2d-x but you have to alter the code to work with marmalade to port to the web. I am not interested in doing this especially if I have to purchase marmalade without knowing for sure the quality and results. Does anyone have positive results using Marmalade’s Quick/OpenQuick?

NaCl : It seems promising but it isn’t updated very well. Anyone have success with this?

Looking forward to hearing other alternatives and thoughts. I posted the same question on stackoverflow: http://stackoverflow.com/questions/33945668/run-cocos2d-x-project-in-browser

Thanks.

Pretty sure Emscripten is the way to go here, but as you’ve found out cocos2d-x only had support for 2.x version and it was fragile even in that version. I don’t believe it’d be too terribly difficult to get it running a number of games have ported to emscripten+asm.js without too much hassle. It’ll be a lot of tedious work for the initial port even if there has been various attempts and work on it done within these forums.

I’m willing to help out with this for fun. If we can get the hello world ‘cocos new’ project working it’ll be easy to go from there. There may be more work in the abstraction of the renderer in v4, but that has been delayed with no timeline.

I’d love to see this working.

Hey stevetranby,

Thanks for helping me out I will keep this post updated with my results. Basically for Emscripten I’ve been following the guide in the description and I get errors thrown at me whenever I execute the “make -f Makefile.emscripten -j 8” command. It doesn’t generate the files it is supposed too. I’m using version 2.2.6: http://www.cocos2d-x.org/download/version

The errors I am getting are clang errors and it is asking for an older clang version (3.2 to be exact), and the new Emscripten is clang 3.7…I don’t know if I can get an older Emscripten with 3.2 clang.

Update: Emscripten 1.10 for linux but clang 3.2 not supported: http://packages.ubuntu.com/trusty/devel/emscripten

I think we need an updated cocos2dx that supports Emscripten clang 3.7…