0

I have faced with problem when I try to build simple project from source using emscripten. Let me describe my acts step by step:

  1. I am using ubuntu 14.04 LTS
  2. install emscripten (I have followed instructions)
  3. install cocos2dx (I have followed instructions on the github)
  4. I have created new project ( I have followed instructions on github too), build it for linux and run, it work good.
  5. Next step I have tried to build for web using emscripten in directory of project i have entered in console:

    cmake -DCMAKE_CXX_COMPILER=em++ -DCMAKE_CC_COMPILER=emcc

    make

Firstly, I have got error with CC_DLL in tinyxml2.h, I removed CC_DLL, And rerun. Then I have got error on unknown include in directory "unzip" ( I have copied zlib.h and zconf.h to directory) and rerun. Then I have got error with GLubyte -use of undeclared identifier, I have added:

#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>

and rerun And Then I have got error use of undeclared identifier 'glDeleteBuffers'; in directory /cocos /2d/CCCameraBackgroundBrush.cpp and many same errors, and I do not know what to do...

Could You help me please how to fix it?

Thank you for any help!

Mike
  • 55
  • 1
  • 7

1 Answers1

2

You can try to use emscripten-port of cocos2d. Just add -s USE_COCOS2D=3 to your build.

I maintain this port, and I already ported with it couple of cocos2dx games.

Now this port is merged only to incoming branch. Also, you can run cocos2d hello world project with this command:

python tests/runner.py browser.test_cocos2d_hello
caiiiycuk
  • 1,466
  • 14
  • 20
  • Thank you for your help! Are there tutorial how to build test project (Quick start , guide, or some sort of guide) ? – Mike Apr 01 '17 at 20:00
  • 1
    You can look at test 'cocos2d_hello' in tests/test_browser.py. Adding only flag -s USE_COCOS2D=3 should be enough to build cocos2d game source file. (./emcc -s USE_COCOS2D=3 game.cpp -o game.html) – caiiiycuk Apr 02 '17 at 17:11
  • I've tried compile (https://github.com/emscripten-ports/Cocos2d) make -s USE_COCOS2D=3 -s STB_IMAGE=1 errors: AR /Cocos2d/lib/linux/release/libchipmunk.a CXX obj/release/CCBReader/CCBFileLoader.o In file included from CCInvocation.h:33:0, from CCNodeLoader.h:4, from CCBFileLoader.h:4, from CCBFileLoader.cpp:1: CCObject.h:106:39: error: ISO C99 requires whitespace after the macro name [-Werror] #define EMULATE_FUNCTION_POINTER_CASTS=1 cc1plus: all warnings being treated as errors make[1]: *** [CCBFileLoader.o] Ошибка 1 make: *** [libextensions] Ошибка 2 – Mike Apr 08 '17 at 11:38
  • And could you tell me please, for which cocos2dx version port is ready ? – Mike Apr 08 '17 at 14:44
  • You do not need to compile escripten-ports/cocos2d. You should install emscripten sdk incoming, and then build you cocos2d project with emcc and flag USE_COCOS2D=3. Cocos2d version is 3.0-pre, also it works with v2 projects with little modifications. You can ask me directly by mail caiiiycuk at gmail.com – caiiiycuk Apr 11 '17 at 04:30