I’m trying to make a little guide, something needs to be retweaked but I think that this will be important for some windows users like me.
Any help would be appreciated for the TODO section, some little imperfection like copying tinyxml and glfw to classes folder for example.
Cocos 2D-x compiling with CLion/CMake under Windows
Installation & Setup
Download Cocos 2d-x latest build [github]
cd cocos2d-x
python download-deps.py
setup.py
cocos new MyGame -p com.your_company.mygame -l cpp -d ProjDir
cd ProjDir/MyGame
Install MSYS2 [download]
start msys2-x86_64-20150512 *(or latest version)*
run msys2
Setup MSYS2 [wiki]
pacman -Sy
pacman --needed -S bash pacman pacman-mirrors msys2-runtime
close MSYS2 and restart with MINGW64 shell
pacman -Su
Install MinGW Packages
- git
- mingw-w64-x86_64-cocos2d-x-git
- mingw-w64-x86_64-cmake
- mingw-w64-x86_64-toolchain
- mingw-w64-x86_64-gcc
- mingw-w64-x86_64-gdb
- mingw-w64-x86_64-qt-creator (optional)
pacman -S git mingw-w64-x86_64-cocos2d-x-git mingw-w64-x86_64-cmake mingw-w64-x86_64-toolchain mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb --force
CLion Setup [download]
Download from JetBrains site, install, then setup.
Settings > Build, Execution, Deployment
> Toolchains
(Environment) > Use MinGW Home: C:\MSYS2\mingw64
(CMake executable) > Use specified: C:\MSYS2\mingw64\bin\cmake.exe
(GDB executable) > MinGW-w64 GDB GNU
> CMake
CMake options: -G"MSYS Makefiles"
Import Project and select ProjDir
Then start to load CMakeLists.txt
If you have errors with Openal not found, install these: (also vorbis, glfw and pkg-config)
pacman -S mingw-w64-x86_64-openal mingw-w64-x86_64-libvorbis mingw-w64-x86_64-glfw mingw-w64-x86_64-pkg-config
Downgrade Chipmunk Lib:
mingw-w64-x86_64-chipmunk-6.2.1-1-any.pkg.tar.xz download
Put package in MSYS2\var\cache\pacman\pkg and then install with:
pacman -U /var/cache/pacman/pkg/mingw-w64-x86_64-chipmunk-6.2.1-1-any.pkg.tar.xz
Change CMakeLists
set(GAME_SRC
${PLATFORM_SPECIFIC_SRC}
)
set(GAME_HEADERS
${PLATFORM_SPECIFIC_HEADERS}
)
file(GLOB ALL_FILES
"Classes/*.h"
"Classes/*.cpp"
)
if(GAME_HEADERS)
add_executable(${APP_NAME} ${GAME_SRC} ${GAME_HEADERS} ${ALL_FILES})
else()
add_executable(${APP_NAME} ${GAME_SRC})
endif()
Could some expert CMake developers say if the “file GLOB” section is correct? This is the only solution I have found for not adding manually all .cpp and .h files
Now reload CMakeLists then Build and cross the fingers!
Useful Links
- [Trying to make CLion working with CMake and Cocos2DX]
- [[Setup] Fastest setup for cocos2d-x on windows with qt-creator debugging]
- [http://discuss.cocos2d-x.org/t/cmake-for-mac-qtcreator-and-clion/16889]
TODO
(aka not working yet)
- Resources bugged, especially if subfolders are present
- Tinyxml2 fixing, avoid copying it in classes folder
- glfw fixing, same as above