Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I need to port a Cocos2D-x project to Web (JS+HTML5). I'm trying to compile cocos2D-x samples using the emscripten project for cocos2d-x, and I've followed this tutorial http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Emscripten_usage without success.

First, I followed the emscripten-specific guide using Linux Mint 15 with this tutorial: https://github.com/kripken/emscripten/wiki/Tutorial

And also on Windows 7 64-bit following this another tutorial: https://github.com/kripken/emscripten/wiki/Using-Emscripten-on-Windows

The emscripten samples worked ok. Then, I downloaded the Cocos2D-x project:

git clone https://github.com/cocos2d/cocos2d-x.git
git submodule update --init --recursive

This version from github, has the "proj.emscripten" project. But, when I try to compile the cocos2D-x project and samples with:

make -f Makefile.emscripten -j 8

...after compiling several modules, it stops at "cocos2d-x/extensions/proj.emscripten" with this error:

mingw32-make[1]: Leaving directory `c:/dev/GitHub/cocos2d-x/CocosDenshion/proj.emscripten'
mingw32-make -C extensions/proj.emscripten all
mingw32-make[1]: Entering directory `c:/dev/GitHub/cocos2d-x/extensions/proj.emscripten'
makefile:12: *** recipe commences before first target.  Stop.
mingw32-make[1]: Leaving directory `c:/dev/GitHub/cocos2d-x/extensions/proj.emscripten'
Makefile.emscripten:21: recipe for target `all' failed
mingw32-make: *** [all] Error 2

This happens on both systems: Windows and Linux. I've installed the same version of the required dependencies that apears on those tutorials. Does anybody know what I'm doing wrong? Is there any easier way to get cocos2D-x running on the web without using the cocos2D-x proj.emscripten?

EDITED: There is an error on cocos2d-x/extensions/proj.emscripten/Makefile file. Changing the line 11 from this:


...to this:

-I../network \

...solves this problem. Now compiles some more modules, but now I'm getting compiler errors, like

error: no member named 'bind' on namespace 'std'

could be a problem with the C++ compiler standards C++0x, C++11...?

share|improve this question

closed as off-topic by Josh Petrie May 13 at 15:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 1 down vote accepted

I solved it!

Mainly there was a problem of typing errors in some files, and the need to specify the C++11 standard in the compile commands. I think that this will be fixed oficially as the project get updated.

These are the steps I done (I asume that previously you have followed the original tutorial from http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Emscripten_usage):

  1. Once you have Cocos2D-x downloaded using git, and Emscripten up and runing with all of its dependencies installed, copy all contents from the emscripten folder to (cocos2d-x-root)/external/emscripten
  2. Copy the truetype font Arial.ttf (download it, or search it from within your system) to the folder: /Library/Fonts/Arial.ttf (it will not work if you don't have it in that place)
  3. Edit cocos2d-x/extensions/proj.emscripten/Makefile

    • Change line 11 from:


    • to:

    -I../network \

  4. Edit cocos2d-x/cocos2dx/proj.emscripten/Makefile

    • Change line 145 from:

    CXXFLAGS += -Wno-sequence-point

    • to

    CXXFLAGS += -Wno-sequence-point -std=c++11

  5. Edit cocos2d-x/samples/Cpp/TestCpp/proj.emscripten/Makefile

    • Add this new line at 474:

    CXXFLAGS += -std=c++11

  6. Edit cocos2d-x/cocos2dx/textures/CCTexture2D.cpp

    • Change line 810 from:


    • to:

    ccTexParams texParams = {(GLuint)(m_bHasMipmaps?GL_NEAREST_MIPMAP_NEAREST:GL_NEAREST),(GLuint)GL_NEAREST,(GLuint)GL_NONE,(GLuint)GL_NONE};

    • and line 830 from:


    • to:

    ccTexParams texParams = {(GLuint)(m_bHasMipmaps?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR),(GLuint)GL_LINEAR,(GLuint)GL_NONE,(GLuint)GL_NONE};

In my case I've got an additional problem (out of memory) when linking the TestCpp project. As I don't need it for now, I simply comment this line at the file cocos2d-x/Makefile.emscripten:

#   +$(MAKE) -C samples/Cpp/TestCpp/proj.$(PLATFORM) $@

Then, when you run:

make -f Makefile.emscripten -j 8

inside the cocos2d-x folder, it should compile without any errors, and you will have the .http, .js and .data files in cocos2d-x/samples/Cpp/HelloCpp/proj.emscripten/bin/release:


Remember to copy those files to some web server and run from there, because It will not work in local. And that's all!

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.