Cocos2d-x 3.X CMake MinGW build and run

Source: Internet
Author: User
Tags webp

Cocos2d-x 3.x already supports the use of CMake for build, Here try to use Qt Creator IDE for CMake build.

 

1. Open Qt creator, open a file or project ...in the menu bar, and open the cmakelists.txt file in the cocos2d-xdirectory;
2. The CMake wizard is displayed, as shown in:

Click the next step to set the path of the cmake.exe file;
3. On the execute CMake interface, select the MinGW item for the builder and click the execute CMake button, as shown in:

4. If there is no error, click Finish. The generated project structure is as follows:

5. to build an MSYS2 environment, you can easily generate a third-party MinGW library. For more information, see MSYS2 environment setup. The following libraries must be generated: zlib, jpeg, png, tiff, webp, freetype, glew, glfw, xz, bzip2, etc. In addition, the libwebsockets library needs to be compiled by yourself. For more information, see "MinGW compiling libwebsockets".
6. Set the environment variables to reference these libraries, switch to the "project" page, and add the variables below "Build Environment:

1
2
  CPLUS_INCLUDE_PATH D: msys2msys32mingw32include
LIBRARY_PATH D: msys2msys32mingw32lib
As shown in:

7. Because glew needs to link to the static library, and the dynamic library and static library in the MSYS2 environment are in the same path, it will first link to the dynamic library. Open the ...cocos2d-xcocosdcmakelists.txt file and change the statement:
1
2
3
4
5
6
7
8
9
10
11
12
  If (WIN32)

If (MINGW)

Set (COCOS_LINK
Z
Jpeg
Png
Webp
Tiff
Glfw3
Glew32
Change glew32 Glew32.a.
8. compile.
9. Copy the DLL required under the D: msys2msys32mingw32in folder to the .. cocos2d-x-buildin estcpp folder. Click project on the left → run, select Run configuration testcpp, set its working directory to: F: MyCodeqtPrococos2d-x-buildin estcppResources, as shown in:

10. Click run in Qt Creator to view the interface, as shown in:


 

In additionIncrediBuildFor joint compilation, you can click Project> build step on the left, disable the previous Make step, and add build step> Custom process step, specify the batch file for joint compilation in the command. You can refer to the article Qt MinGW joint compilation IncrediBuild. As shown in:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.