[Setup] Fastest setup for cocos2d-x on windows with qt-creator debugging

Hey Guys,

Windows users need some love too so here is the fastest cocos2d-x setup guide yet.
Soon you will all be able to build for linux mac ios and android all from windows.
For now here is the initial support for the fastest windows build ever

Step 1. [download: msys2][1]

Step 2. Install git and mingw-cocos2d-x-git and qt-creator via
pacman -S git mingw-w64-x86_64-cocos2d-x-git mingw-w64-x86_64-qt-creator mingw-w64-x86_64-cmake

Step 3 clone the template project I created
git clone https://github.com/martell/cpp-template-default.git

Step 4 Run qtcreator and open the CMakeLists.txt
start /mingw64/bin/qtcreator or via windows explorer directly


If you are asked where cmake.exe is. It is in the relative msys/mingw directory.
NB Please always use the mingw cmake

Step 5 Run Cmake with the Mingw Generator and Finish


Step 6 build and run
Note: Todo a 32 bit build version replace x86_64 with i686 and mingw64 with mingw32 in all steps

Step 7 Optional install gdb and debug will now work :slight_smile:
pacman -S mingw-w64-x86_64-gdb  

Troubleshooting

If qtcreator fails to start please

  1. Uninstall the packages
    pacman -R mingw-w64-x86_64-qt5 mingw-w64-x86_64-qbs mingw-w64-x86_64-qt-creator
  2. Reinstall from cache
    pacman -S mingw-w64-x86_64-qt-creator
    Don’t worry it won’t re download them
3 Likes

Yep, it sounds good.
But i think most users need VS too to debug codes.

In order to have the same dev environment on all platforms with debugging capabilities, it would be great to be able to use Qt Creator with the same project file on Windows, Mac and Linux.

@zhangxm You don’t need Visual Studio to debug.
All the packages were built with mingw64 so gdb can debug them.
We would just use qt creator for this

Users will need visual studio for phone and RT though so we won’t retire visual studio just yet :wink:

@Chano you can infact do that. pacman has both qt-creator and gdb.
Just type pacman -S mingw-w64-x86_64-qtcreator and you are good to go :wink:

I will create a template today that works across all three platforms with that exact setup.
All debugging from qtcreator and usable from and of the three platforms :smile:

Thanks, but Windows already has loads of native development tools. But debugging with VS is usually easy as pie.
I was really hoping you’d be demonstrating how to join CocoStudio output to our eclipse projects…

bump please re evaluate now that there qt creator has been added :stuck_out_tongue:

Thanks a lot!

However, I can’t test it because currently I only have a Mac :stuck_out_tongue:

But it would be great if cocos2d-x would provide an environment like this for the easiest multiplatform compiling and debugging.

Qt Creator can also work with Visual Studio compiler and libs, so on Windows it would not be limited to MinGW.

Hi Chano,

Thats no problem I will be porting this to mac soon so you can join in the fun. :wink:

The msys2 team are still debating if pacman should be ported to mac also.
To streamline the process like on windows.
There is already the homebrew package manager for this so I could just use that also

Currently you have to install Qt Creator from the website on mac and of course xcode to get compilers.

Yes you are right Qt Creator can use the Visual Studio Compiler.
It can now in fact invoke the tools for Windows RT and Windows Phone and even debug it.
http://blog.qt.digia.com/blog/2014/03/05/experimental-version-of-qt-creators-winrt-plugin/

It can also do this for IOS.
http://blog.qt.digia.com/blog/2013/12/10/cross-platform-applications-in-ios-and-android-stores-with-qt/

So essentially you can build for ever platform from Qt creator.
You just need xcode and visual studio installed also to access the IOS WinRT and WP8 tools

Android just needs the NDK and Android SDK for this support.

I’m surprised that no project has ever made QtCreator it’s official Editor considering it really solves all cross platform requirements. Like why would anyone use Eclipse when we have this.

strong textwhat’s pacman? can’t you just list download links and leave me to figure everything out when my internet breaks, please?

pacman is within cygwin?

@nuttypros
There is no cygwin here?
This is msys2

pacman is the package manager provided with msys2
you use it to install packages.
It is explained above but here is a more in dept guide.

pacman is run from the msys2 bash like in the screenshots above.

pacman -Syu updates installed packages and refreshes the list from the server
pacman -S <packagename> installs a package
pacman -Ss <partname> querys for a package

If you want a visual package manager we have the octopi package
You will have to install that with pacman. In future it may be provided by default.
It’s very alpha quality atm though.

So lets query go through how you find and install a package

  1. Let update our system and package lists first with
    pacman -Syu

  2. Then lets see if octopi actually exsists
    pacman -Ss octopi

    That should then list two possible packages to install (one for x86 and one for x64)
    Then use pacman -S <packagename> to install the one you want

  3. Lets install the package (I picked the 64bit version)
    pacman -S mingw-w64-x86_64-octopi-git

Then after install I could simple type
start /mingw64/bin/octopi
to start it

You can manage the installed packages with this gui tool.
Be warned it is very alpha quality and may be broken in parts
I recommend sticking with using pacman for now directly for now.

If you have any problems let me know
:smile:

@zhangxm It’s live now if you want to test.
Currently qt-creator package is dependant on the qt5-sdk so it is a 500mb download
That will hopefully change in the next week or so making the full install from
Zer0 to coco2d-x hero just under 200mb :wink:

If only, hero, lol. I really need to try and integrate cocostudio output into my C++ with cocos2dxv3.1.1. That would be RAD. But reading the cocos2d-x API and samples will take me weeks. Zero to DemoCowboy in one week :wink:

I’ll have a look at getting cocos2d-x help into the qt-creator help to help you speed along.
You do know that there is a test for every single feature. The cocostudio ones are here in extensions.


That should change that week into 10 minutes or at least only a few hours :stuck_out_tongue:

Yes! With Qt Creator you can build and debug for a lot of platforms using the same .pro file.

More yes :smiley: ! For me it’s the best way to handle a C++ multiplatform dev environment.

any news? Did anyone used this for real and tried it? Updates? Anything? ^^

when I create a new project and i compile that.
it has a compile error, always crush in here

E:\Workspace\Cocos2dx\pvz\cocos2d\cocos\base\CCPlatformConfig.h
// check user set platform
#if ! CC_TARGET_PLATFORM
#error “Cannot recognize the target platform; are you targeting an unsupported platform?”
#endif

pvz is my project name

Hi, @kimspirit. I am very new to Cocos2D-X and I just followed this tutorial to install this development environment (everything went great…thanks a ton @Martell :smiley: ), so I don’t know how much help this will be but maybe this will help you along a bit (sorry if this doesn’t help at all).

I am going to follow Sonar Systems YouTube tutorials using the project that Martell provides in this tutorial. Rather than trying to create a new project within QT Creator (there wasn’t a project type for Cocos2D-X) I just pulled Martell’s project a second time and edited the CMakeLists.txt file to change the app name from ‘MyGame’ to what I wanted it to be. In this case it is ‘FlappyBirds’ because that is the tutorial from Sonar Systems that I will be attempting to reproduce. Maybe you could do the same to get your project up and running. I hope this helps you.

Hi @kimspirit. It is just as @Rabidgoalie said you have to use the sample I created in my repo.
Otherwise you will get that undefined error.

I am currently doing a PR to fix more with this in cocos2d-x and after that point this package should be available on stable release versions and not just -git head

@Rabidgoalie I’m glad you like it :slight_smile: I will make it even better soon :wink:

thank you @Rabidgoalie about your advice,
and @Martell I just want to Cocos2d-x becoming better…