Build Cocos2d-x Samples

Updated: 05/13/2021

This page is for Cubism version 4.2 or earlier. Click here for the latest version.

This page describes how to compile the Cocos2d-x sample project included in the Live2D Cubism SDK for Native with Visual Studio in a Windows environment.

Note: The content of this article is based on the Cubism 4 SDK for Native R3.
The method and procedure may differ depending on the Cubism SDK version. 

What to Download

Live2D Cubism SDK for Native

The main body of the SDK. Download from the “official download page.”


This is the library used in the SDK.
This can be downloaded using the batch file included in the Cubism SDK sample.


Used to generate project files.

Visual Studio

This is the development environment that will be used here. The language will be C++.

Installation process

1. Visual Studio

Install the integrated development environment.
Set up the system so that C++ can compile.
Please use Visual Studio 2015 or later.

2. CMake

Install CMake.
CMake operations are used from a batch file, so the CMake path setting should be set so that it can be referenced by the user who will use it.

Note: Images may differ from the actual screen. 

3. Cocos2d-x

Install Cocos2d-x.

Run “setup_cocos2d.bat” in “/Samples/Cocos2d-x/thirdParty/scripts” to download Cocos2d-x.

When the batch processing is completed, a folder named “cocos2d” is created in “/Samples/Cocos2d-x/thirdParty.”

If you have already downloaded the software, create a folder named “cocos2d” in “/Samples/Cocos2d-x/thirdParty” and extract your Cocos2d-x into it.

In addition, the environment building scripts included with the Cubism SDK execute scripts included with Cocos2d-x, etc., so an environment for executing these scripts is also required.
See the official Cocos2d-x README for details.

Execute CMake

CMake can also be used from the GUI, but at this time use the batch file included in the sample.
The batch file can be found in “Samples/Cocos2d-x/Demo/”

In this example, the “proj_msvc2015.bat” file is executed to select the project containing the Visual Studio 2015 solution file.

When executed, choices will be displayed as shown in the image below, so enter the corresponding number in single-byte numbers.

• Selecting modules for Cubism Core

Select the Cubism Core runtime library to be used.
See the official Microsoft documentation for the meanings of MD, MT, etc.

If the input is successful, CMake generation will begin.
Note: If an error occurs after the generation starts, please check the version of CMake and the version of Visual Studio you are specifying.


When CMake generation is finished, open the solution file from the generated files.
In this example, execute
• proj_msvc2015.bat

and select
• use the multithread-specific and DLL-specific version of the run-time library (MD)

and then
open the output file “Demo.sln” in “[root]/Samples/Cocos2d-x/Demo/” in Visual Studio and execute the build.


If the build is successful, let’s run it through debugging.

If a large screen appears, you have succeeded.

To adjust the window size, change the values of the 1st and 2nd arguments of cocos2d::Size used in “/Sample/Cocos2d-x/Demo/Classes/AppDelegate.cpp.”

static cocos2d::Size designResolutionSize = cocos2d::Size(LAppDefine::RenderTargetWidth, LAppDefine::RenderTargetHeight);

Note: Actual values for RenderTargetWidth and RenderTargetHeight are defined in “/Sample/Cocos2d-x/Demo/Classes/LAppDefine.cpp.”

Let’s build and run it again.

At this point, the “rebuild solution” will take as long as the first build, so select “Build Demo.”

If you want to rebuild due to problems, select “Project Only > Rebuild Demo Only” to complete the rebuild in a relatively short time.

Was this article helpful?
Please let us know what you think about this article.