Can someone tell me how to setup cocos2d-x on Code::Blocks?

Hi everyone,

I’ve read that it was possible to use cocos2d-x with Code::Blocks, but I can’t find any tutorial on how to do it.
Actually, I can’t find any help whatsoever…
Code::Blocks configuration possibilities are huge, but it’s a maze when you don’t know it perfectly.
Plus, I’ve never used cocos2d-x before, and all installation tutorials on windows seem to only concern VisualC++ (and I’m not using “this”).

Thanks to anyone who can give me directions :slight_smile:

I’m sorry to insist, but I really need this.
I can’t believe that absolutely no one knows how to make it work with code::blocks…

I am sorry, i am not familiar with Code::Blocks. Could you say something about it?

Ok, i found it. It is an open source C++ IDE.
Any benefit of using it?

I could argue for hours on the fact that it’s an awesome IDE, that you can use it for pretty much anything, that it never crashes, that it makes developing super dupper easy, blah blah blah…
But the real reason is that I’m used to it and its specificities, and that I have had some bad experiences with VisualC++.
And I’m of those guys who tend to say “it’s open source, so it has to be better” :stuck_out_tongue:

1 Like

But most developers on windows use VS and Xcode on Mac. We should support most developers’ choice. I think it is easy to support Code::Blocks, but it will cost many resources to maintain it, test it.

So i think you can use it since you like it. But we have too limited resources to support it.

@zhangxm Code::Blocks is a cross-platform IDE linux/windows/mac and how says Kicker it’s awesome :slight_smile:

@zhangxm Is there a project creator for Linux/Unix users?

Restricting to only Mac/Windows, excludes a lot of *nix developers.
On linux/unix platforms, Code::Blocks is one of the most popular C++ IDEs.

I think there should be a basic toolset documentation using GCC/binutils toolchain, make files etc for Linux platforms.

Already Cocos2d-x games are running on Linux - But how to configure development tools on Linux is not documented.
Also, Linux developers happen to be one of the major contributors to open source software. Cocos2d-x project can only benefit by opening up cocos2d-x development to those on Linux (Ubuntu, Fedora, Debian etc) / Unix by documenting a way to create and run projects with basic commandline tools and text editors.

There is already documents for how to create and run a project on Linux: http://cocos2d-x.org/news/203.

Now we use cmake to generate makefile, then build the project. If we want to support another IDE, then it will be hard to maintain. So i think we can just choose one way

  • use cmake and vim/emacs as it is now
  • use an IDE to manage linux project, the IDE could be Code::Blocks

Any thought?

If you are using linux, then building cocos2d-x with CodeBlocks is quite easy. You could use cmake generators for creating a CodeBlocks project (cbp) for building your Cocos2d-x game.

You can do this by simply going to your project’s proj.linux directory and type

cmake ../ -G "CodeBlocks - MinGW Makefiles"

Then , open the cbp file created in your proj.linux directory using CodeBlocks, and start coding.

Please note that the project generated by the cmake CodeBlocks generator is configured as a Command only project , which will give you the following error when you are trying to run the Cocos2d-x game.

You must select a host application to "run" a commands-only target...

In order to solve this issue right click on your CodeBlocks project >> Properties >> Build targets >> Type >> Console Application >> Type the correct output file name (located at the bin directory. And you’re all set!

Happy CodeBlocks Cocos2d-x game programming! :smile:

Thank you, raydelto. With your tips I managed to setup a codeblocks project. But how can I make the debugger work? I set breakpoints and click the red play (debug) button but it will not stop on the breakpoints.

Edit> I’ve found the answer to my own question. You only have to pass the CMAKE_BUILD_TYPE in the command line setting it to Debug. For example:

cmake -DCMAKE_BUILD_TYPE=Debug …/ -G “CodeBlocks - Unix Makefiles”

With this I can debug using codeblocks on my linux machine. :slight_smile:

1 Like

Hello ,

Whenever i am trying to run following command it give me following errors of the cmake files.
I have cmake directory in which files are existed but there are some files are not existed.
so i am trying to find these kind of files but i am not able to find correct missing files.
so i am not able to run projects in code block ide.
Please give a right solution to solve this problem.

You can solve your problem using following link

1 Like

Is this process helped to use Code::Blocks on linux?
I didn’t found the detailed steps to use on linux.
I am quite new on linx as well as on cocos2dx.

hey folks try t use CLion from JetBrains - it is very comfortable IDE for programmers.

Based on raydelto youtube video example, I’ve written a dummy python script to generate a CodeBlock’s Cocos2D project based only on the name and the “domain” of the app. I’ve not tested it thoroughly, but it should work in most cases. You’ll need to change projectDir at the start to whatever directory you want to store your projects.

#!/usr/bin/env python

import sys
import os

projectDir = os.path.expanduser("~/Desktop/CodeBlocks/Cocos2D/")
cocosCommand = r"cocos new {} -p {} -l cpp -d "+projectDir
cmakeCommand = r"cmake -G 'CodeBlocks - Unix Makefiles'"

def genProject(name, domain):
        # Create cocos project
        cocosCmd = cocosCommand.format(name, domain)
        if os.system(cocosCmd) == 0:
                print ("Cocos2d-x project created succesfully")
        else:
                print ("ERROR while creating Cocos2d-x project")
                print ("Command was: "+cocosCmd)
        # Change to project's directory
        os.chdir(projectDir+name)
        # Gen CodeBlocks project
        cmakeCmd = cmakeCommand
        if os.system(cmakeCmd) == 0:
                print ("CodeBlocks project created succesfully")
        else:
                print ("ERROR while creating CodeBlocks project")
                print ("Command was: "+cmakeCmd)


#
# Main program
#

if len(sys.argv) != 3:
        print ("Usage:\n")
        print ("\t"+sys.argv[0]+" <project-name> <project-domain>")
        print ("\tExample:");
        print ("\t\t"+sys.argv[0]+" MyProject net.example.myproject")

genProject(sys.argv[1], sys.argv[2])
1 Like

The most easy way i found to programming in Linux is using QTCreator, i try C:B but i can’t found easy way to configure it.

In QTCreator u only need open the project using CMakeLists.txt .