Error when building cpp-test on cocos2d-x 4.0

Hi,

I start by following the guide here. https://docs.cocos2d-x.org/cocos2d-x/v4/en/installation/Windows.html

Regarding prerequisites:

  • Windows 7+ - have windows 10
  • VS 2017+ - have visual studio 2019
  • CMake 3.1+ - installed latest
  • Python 2.7.5+, Python 2,7.10 reccomended , NOT Python 3+ - installed Python 2.7.10

Download Cocos2dx v4 from github repo.

I run this command

python setup.py

Then i run this command

cd COCOS2DX/tests/cpp-tests
mkdir win32-build
cd win32-build
cmake ..

Then I rebuild the generated solution and get this error.

Please advise.

Thanks.

Your last cmake command is wrong. It should be:

cmake .. -G"Visual Studio 16 2019" -AWin32

If you use it as you have tried, cmake will make a 64bit solution and cocos is not compatible with it out of the box so you have to specify the 32bit command.

1 Like

Did you follow the instructions on that page completely? The reason I ask is because I don’t see the following 2 lines in your screenshots:

git submodule update --init
./download-deps.py

found the root cause. x64 is not supported. had to use x32.

I tried with cocos run -p win32, and get the same error.
Please advise.

Microsoft Windows [Version 10.0.18363.476]
(c) 2019 Microsoft Corporation. All rights reserved.

D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests>cocos run -p win32
Xiamen Yaji Software Ltd. collects anonymous data when the command-line tools are used for development. This data is examined in the aggregate only and is used to continually innovate and improve Cocos products. This data is anonymous and includes, but is not limited to, a unique hardware identifier, version number our software and information on which tools and/or services in Cocos products are being used and how they are being used. We take your privacy seriously and we do not share or sell any of this data. You can opt-out from sharing this data with us, but by sharing you help contribute to growth of Cocos.

Our entire policy can be viewed at: http://www.cocos2d-x.org/licenses.

For questions please e-mail privacy@cocos2d-x.org.

Do you agree to sent the data? [Y]es, [N]o
y
Building mode: debug
Can not find VS version or not specified
running: 'cmake ..'

-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- PROJECT_NAME:cpp-tests
-- PROJECT_SOURCE_DIR:D:/Cocos2d-x/cocos2d-x-4.0/tests/cpp-tests
-- COCOS2DX_ROOT_PATH:D:/Cocos2d-x/cocos2d-x-4.0/tests/cpp-tests/../..
-- CMAKE_MODULE_PATH:D:/Cocos2d-x/cocos2d-x-4.0/tests/cpp-tests/../../cmake/Modules/
-- PROJECT_BINARY_DIR:D:/Cocos2d-x/cocos2d-x-4.0/tests/cpp-tests/win32-build
-- ENGINE_BINARY_PATH:D:/Cocos2d-x/cocos2d-x-4.0/tests/cpp-tests/win32-build/engine
-- PYTHON_PATH:D:/Python27/python.exe
-- COCOS_COMMAND_PATH:D:/Cocos2d-x/cocos2d-x-4.0/tools/cocos2d-console/bin/cocos
-- HOST_SYSTEM:Windows
-- CMAKE_GENERATOR: Visual Studio 16 2019
-- using Windows MSVC generate cocos2d-x project, MSVC_VERSION:1924
-- COCOS2DX_LUAJIT_ROOT:D:/Cocos2d-x/cocos2d-x-4.0/tools/cocos2d-console/bin/../plugins/plugin_luacompile/bin
-- LUAJIT32_COMMAND:D:/Cocos2d-x/cocos2d-x-4.0/tools/cocos2d-console/plugins/plugin_luacompile/bin/32bit/luajit-win32.exe
-- LUAJIT64_COMMAND:D:/Cocos2d-x/cocos2d-x-4.0/tools/cocos2d-console/plugins/plugin_luacompile/bin/64bit/luajit-win32.exe
-- cocos_mark_code_files: cocos2d
-- cocos_mark_code_files: cpp-tests
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Cocos2d-x/cocos2d-x-4.0/tests/cpp-tests/win32-build
running: 'cmake --build . --config Debug'

Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Copying resources for cpp-tests ...
  Building Custom Rule D:/Cocos2d-x/cocos2d-x-4.0/tests/cpp-tests/CMakeLists.txt
      copying to D:/Cocos2d-x/cocos2d-x-4.0/tests/cpp-tests/win32-build/bin/cpp-tests/Debug/Resources
  ext_clipper.vcxproj -> D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\lib\Debug\ext_clipper.lib
  ext_convertUTF.vcxproj -> D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\lib\Debug\ext_convertUTF.lib
  ext_edtaa3func.vcxproj -> D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\lib\Debug\ext_edtaa3func.lib
  ext_md5.vcxproj -> D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\lib\Debug\ext_md5.lib
  ext_poly2tri.vcxproj -> D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\lib\Debug\ext_poly2tri.lib
  ext_recast.vcxproj -> D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\lib\Debug\ext_recast.lib
  ext_tinyxml2.vcxproj -> D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\lib\Debug\ext_tinyxml2.lib
  ext_unzip.vcxproj -> D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\lib\Debug\ext_unzip.lib
  ext_xxhash.vcxproj -> D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\lib\Debug\ext_xxhash.lib
  ext_xxtea.vcxproj -> D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\lib\Debug\ext_xxtea.lib
  external.vcxproj -> D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\lib\Debug\external.lib
  UIEditBoxImpl-win32.cpp
D:\Cocos2d-x\cocos2d-x-4.0\cocos\ui\UIEditBox\UIEditBoxImpl-win32.cpp(64,70): error C2065: 'GWL_WNDPROC': undeclared id
entifier [D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\engine\cocos\core\cocos2d.vcxproj]
D:\Cocos2d-x\cocos2d-x-4.0\cocos\ui\UIEditBox\UIEditBoxImpl-win32.cpp(101,42): error C2065: 'GWL_WNDPROC': undeclared i
dentifier [D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\engine\cocos\core\cocos2d.vcxproj]
D:\Cocos2d-x\cocos2d-x-4.0\cocos\ui\UIEditBox\UIEditBoxImpl-win32.cpp(124,40): warning C4312: 'type cast': conversion f
rom 'int' to 'HMENU' of greater size [D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\engine\cocos\core\cocos2d.
vcxproj]
D:\Cocos2d-x\cocos2d-x-4.0\cocos\ui\UIEditBox\UIEditBoxImpl-win32.cpp(128,42): error C2065: 'GWL_USERDATA': undeclared
identifier [D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\engine\cocos\core\cocos2d.vcxproj]
D:\Cocos2d-x\cocos2d-x-4.0\cocos\ui\UIEditBox\UIEditBoxImpl-win32.cpp(129,66): error C2065: 'GWL_WNDPROC': undeclared i
dentifier [D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\engine\cocos\core\cocos2d.vcxproj]
D:\Cocos2d-x\cocos2d-x-4.0\cocos\ui\UIEditBox\UIEditBoxImpl-win32.cpp(246,34): warning C4267: 'initializing': conversio
n from 'size_t' to 'int', possible loss of data [D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\engine\cocos\co
re\cocos2d.vcxproj]
D:\Cocos2d-x\cocos2d-x-4.0\cocos\ui\UIEditBox\UIEditBoxImpl-win32.cpp(280,22): warning C4244: 'argument': conversion fr
om 'const float' to 'int', possible loss of data [D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\engine\cocos\c
ore\cocos2d.vcxproj]
D:\Cocos2d-x\cocos2d-x-4.0\cocos\ui\UIEditBox\UIEditBoxImpl-win32.cpp(279,22): warning C4244: 'argument': conversion fr
om 'const float' to 'int', possible loss of data [D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\engine\cocos\c
ore\cocos2d.vcxproj]
D:\Cocos2d-x\cocos2d-x-4.0\cocos\ui\UIEditBox\UIEditBoxImpl-win32.cpp(278,24): warning C4244: 'argument': conversion fr
om 'const float' to 'int', possible loss of data [D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\engine\cocos\c
ore\cocos2d.vcxproj]
D:\Cocos2d-x\cocos2d-x-4.0\cocos\ui\UIEditBox\UIEditBoxImpl-win32.cpp(277,24): warning C4244: 'argument': conversion fr
om 'const float' to 'int', possible loss of data [D:\Cocos2d-x\cocos2d-x-4.0\tests\cpp-tests\win32-build\engine\cocos\c
ore\cocos2d.vcxproj]
Error running command, return code: 1.

perhaps this is part of it?

I think there is a bug in cocos run command somewhere as it still makes a 64bit solution.

Let us try doing it from scratch with Visual Studio.

  1. Delete the win32-build folder you made
  2. Run download-deps.py
  3. Run setup.py
  4. Make win32-build folder inside COCOS2DX/tests/cpp-tests
  5. Open cmd, go to win32-build folder and
    cmake … -G"Visual Studio 16 2019" -AWin32
  6. Open cpp-tests.sln
  7. Build and run the project

Just tried this and it works for me. The cocos run does not work as it still makes a 64bit solution.

1 Like

Why my post is not in order? Problem is solved already. My last post is

found the root cause. x64 is not supported. had to use x32.

I downloaded zip package.

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