Linux Installation and Setup

Prerequisites

A supported environment. See Installation Prerequisites

Ubuntu versions

We support Ubuntu 12.10+, however, newer versions of Ubuntu have changed and the steps to install Cocos2d-x and required dependencies are a bit different. This requires some manual effort and this doc will outline what is required.

Setting up Cocos2d-x

You can get started with Cocos2d-x by either downloading a self-contained .zip from the website or by cloning our GitHub Repo. Pick what works for you. There is no need to do both.

By downloading a .zip archive

Download Cocos2d-x and unzip it. (maybe: ~/ or ~/Projects )

Cloning from GitHub

Use the following commands to clone our GitHub repo and get your environment setup. If you are not familar with GitHub's workflow, learn it or download using the step above, By downloading a .zip archive.

Install Python

// Ubuntu 16.x
sudo apt-get install python2

// Ubuntu 17.x
sudo apt-get install python2.7

// Ubuntu 18.x
sudo apt-get install python-minimal

Clone Repo and setup dependencies

sudo apt-get install git

cd <to where you want to clone this repo>

git clone https://github.com/cocos2d/cocos2d-x.git

cd cocos2d-x-root #where your cocos2d-x directory is located.

git submodule update --init

git submodule update

./download-deps.py

Make sure you have a working environment!

See Prerequisites above. This means a working Python, having run cocos2d-x root/setup.py, updated your $PATH and run source ~/.bash_profile.

Dependencies that you need

Cocos2d-x requires a number of dependencies be installed on your system. Please perform the following steps:

Update your system, execute:

  sudo apt-get update
  sudo apt-get upgrade

Install Dependencies (Ubuntu 16.x only)

  1. Install dependencies
    // Ubuntu 16.x
    sudo apt-get install g++ libgdk-pixbuf2.0-dev python-pip cmake libx11-dev libxmu-dev libglu1-mesa-dev libgl2ps-dev libxi-dev libzip-dev libpng-dev libcurl4-gnutls-dev libfontconfig1-dev libsqlite3-dev libglew-dev libssl-dev libgtk-3-dev libglfw3 libglfw3-dev xorg-dev
    

Install Dependencies (Ubuntu 17.x only)

  1. Add a repo to /etc/apt/sources.list

    deb //cz.archive.ubuntu.com/ubuntu xenial main
    
  2. Install Dependencies

    sudo apt-get install g++ libgdk-pixbuf2.0-dev python-pip cmake libx11-dev libxmu-dev libglu1-mesa-dev libgl2ps-dev libxi-dev libzip-dev libpng-dev libcurl4-gnutls-dev libfontconfig1-dev libsqlite3-dev libglew-dev libssl-dev libgtk-3-dev libglfw3 libglfw3-dev xorg-dev
    

Install Dependencies (Ubuntu 18.x only)

  1. Install dependencies.

    sudo apt-get install g++ libgdk-pixbuf2.0-dev python-pip cmake libx11-dev libxmu-dev libglu1-mesa-dev libgl2ps-dev libxi-dev libzip-dev libpng-dev libcurl4-gnutls-dev libfontconfig1-dev libsqlite3-dev libglew-dev libssl-dev libgtk-3-dev libglfw3 libglfw3-dev xorg-dev
    

Building Cocos2d-x

  • Run cmake to generate makefile:

    cd cocos2d-x-root # where your cocos2d-x directory is located.
    cd build
    mkdir linux-build
    cd linux-build
    cmake ../..
    
  • When cmake finishes, many files & folders will be generated in coocs2dx_root/build/linux-build

  • Run make to compile:

    make -j 4
    

    Everything will be generated in cocos2dx_root/build/linux-build/bin/cpp-tests/ if compiled successfully.

  • Run cpp-tests

    cd cocos2dx_root/build/linux-build/bin/Debug/cpp-tests/
    ./cpp-tests
    

Starting a new project

Once everything above works, you can start a new project! To do this, read our document on the Cocos Command-line tool.

Troubleshooting

Please see this F.A.Q for troubleshooting help. Linux has a few known issues.

results matching ""

    No results matching ""