Cocos2d-x in Ubuntu 16.04

Posted on December 9, 2019

So i was trying to install and setup the cocos2d game engine in Ubuntu 16.04 so I can get started on a c++ project.

I followed the documentation http://cocos2d-x.org/docs/installation/Linux/index.html

Everything was fine untill i tried to compile  and run the cpp-tests. So I made a little search and found that before run install-deps-linux.sh I should make some library fixes:

 

First I had to remove libglfw2

sudo apt-get remove libglfw2

Then move manualy fmod (while you are inside cocos folder)

sudo cp external/linux-specific/fmod/prebuilt/64-bit/libfmod.so /usr/local/lib/
sudo cp external/linux-specific/fmod/prebuilt/64-bit/libfmodL.so /usr/local/lib/

...and create symbolic link in /usr/local/lib/

ln -s libfmod.so libfmod.so.6

After that I had to reinstall dependecies in folder /build

./install-deps-linux.sh

 

Sources:

https://github.com/cocos2d/cocos2d-x/issues/9805

https://github.com/cocos2d/cocos2d-x/issues/15137

http://discuss.cocos2d-x.org/t/error-while-building-for-linux-libfmod-so-6/26553/14

 

Creating your first project

You follow the documentation http://cocos2d-x.org/docs/editors_and_tools/cocosCLTool/

In case you are going c++ to compile in linux you follow these steps:

From the terminal check cocos version

cocos -v

Create a hello world project

cocos new my_game -p com.MyCompany.my_game -l cpp -d MyCompany

Compile it

cocos compile -s ~/MyCompany -p linux -m release -o ~/MyCompany/my_game/bin

Then run it

./MyCompany/my_game/bin/my_game

 

Tip: If you create new files in Classes folder should update set(GAME_SRC and set(GAME_HEADERS in CMakeLists.txt file