[Vs2017] Need help to build *.EXE Win32 Release Mode

Hello all!

  • I used Vs2019, but cocos2d-x doesn’t support for it when build *.exe, So I removed it first.
  • I install Vs2017 [build tool 141] and run in VS oke,
  • I go CMD to build DEBUG mode :
    cocos compile -p win32 // everything oke
  • But with:
    cocos deploy -p win32 -m release
    I got :
    “1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(67,5): error MSB8020: The build tools for v142 (Platform Toolset = ‘v142’) cannot be found. To build using the v142 build tools, please install v142 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting “Retarget solution”.”

It’s weird error, because BuildTool v142 cannot be installed on Vs2017. It’s oke on Vs2019 (2019 cannot build file *.exe)

Oh my god, someone can help me.

Are you using the Visual Studio solution file that is located in the [YourProjectRoot]\proj.win32\? If so, don’t, since that project is not the correct one to use. Don’t modify that folder in any way.

You didn’t mention CMake, so if you’re not using it, then you need to in order to generate the correct Visual Studio 2019 project (you could even use VS2022 etc).

Try this from the root folder of your Cocos2d-x project:

mkdir build-win32
cd build-win32
cmake .. -G"Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release

That will generate the VS2019 solution files in the build-win32 folder. Open the generated build-win32/[projectname].sln file that you see in there, and that should work.

If you want to use VS2017, then it will be this command to create the project files:
cmake .. -G"Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=Release

If none of the above help, then try the CMake instructions at this link:
https://github.com/cocos2d/cocos2d-x/tree/v3/cmake

1 Like

thank you for rely!
I tried to build .exe inside VS2019 (don’t use cocos CMD). So, I’ll try with your mention.
Thanks again.

What I mentioned in my post is how you need to generate the project files for VS2019, and once that step is done, open the project in VS2019.

1 Like

Hi R101:
your ‘cmake … -G"Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release’,
Make me error when clicking Build In VS:
lack of ’ lib\Release\cocos2d.lib ’
But: cmake … -G"Visual Studio 16 2019" -A Win32 -Tv142 // enough lib to build
I built a release mode for game with file *.exe has game_icon
Thank you!

Yes, the correct line to use would be:

VS2019:
cmake .. -G"Visual Studio 16 2019" -Tv142 -A Win32

VS2017:
cmake .. -G"Visual Studio 15 2017" -Tv141

VS2022:
cmake .. -G "Visual Studio 17 2022" -A Win32

The one with the cmake … -G"Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release is from https://github.com/cocos2d/cocos2d-x/tree/v3/cmake#build-options, but I’m not sure if that info is up-to-date.

Use whatever works for you.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.