cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.21k stars 7.06k forks source link

cocos2d-x failed to build on Windows due to fatal error C1083: Cannot open include file: 'bullet/LinearMath/btIDebugDraw.h': No such file or directory #17966

Closed KarenHuang2016 closed 6 years ago

KarenHuang2016 commented 7 years ago

Environment: Windows Server 2012 R2 + VS2015 Update 3 + cocos2d-x v3 branch latest srouce code

We tried to build cocos2d-x on Windows. It failed due to fatal error C1083: Cannot open include file: 'bullet/LinearMath/btIDebugDraw.h': No such file or directory. This issue is caused by v3 branch revision 4ce443b . It seems the cl command lacks the include path for btIDebugDraw.h. Could you please take a look at this? Thanks in advance!

Steps to Reproduce:

  1. git clone --recursive https://github.com/cocos2d/cocos2d-x.git D:\Cocos2dx\src
  2. Open a VS 2015 x86 command prompt and browse to D:\Cocos2dx\src
  3. python download-deps.py -r None
  4. cmake -G "Visual Studio 14" -DCMAKE_SYSTEM_VERSION=10.0.14393.0 ..\src
  5. msbuild /m /p:Configuration=Release;Platform=Win32 build_x86\Cocos2d-X.sln /t:Rebuild

Actual result: The full log file is attached. cocos2dx_x86_build.txt

   "D:\Cocos2dx\build_x86\Cocos2d-X.sln" (Rebuild target) (1) ->
   "D:\Cocos2dx\build_x86\cocos\cocos2d.vcxproj.metaproj" (Rebuild target) (3) ->
   "D:\Cocos2dx\build_x86\cocos\cocos2dInternal.vcxproj.metaproj" (Rebuild target) (4) ->
   "D:\Cocos2dx\build_x86\cocos\cocos2dInternal.vcxproj" (Rebuild target) (15) ->
   (ClCompile target) -> 
     D:\Cocos2dx\src\cocos\physics3d/CCPhysics3DDebugDrawer.h(37): fatal error C1083: Cannot open include file: 'bullet/LinearMath/btIDebugDraw.h': No such file or directory (s:\dd\feature\winc\src\vctools\compiler\cxxfe\sl\p1\c\p0prepro.c:1654) [D:\Cocos2dx\build_x86\cocos\cocos2dInternal.vcxproj]
     D:\Cocos2dx\src\cocos\physics3d/CCPhysics3DDebugDrawer.h(37): fatal error C1083: Cannot open include file: 'bullet/LinearMath/btIDebugDraw.h': No such file or directory (s:\dd\feature\winc\src\vctools\compiler\cxxfe\sl\p1\c\p0prepro.c:1654) [D:\Cocos2dx\build_x86\cocos\cocos2dInternal.vcxproj]
     D:\Cocos2dx\src\cocos\physics3d/CCPhysics3DDebugDrawer.h(37): fatal error C1083: Cannot open include file: 'bullet/LinearMath/btIDebugDraw.h': No such file or directory (s:\dd\feature\winc\src\vctools\compiler\cxxfe\sl\p1\c\p0prepro.c:1654) [D:\Cocos2dx\build_x86\cocos\cocos2dInternal.vcxproj]
     D:\Cocos2dx\src\cocos\physics3d/CCPhysics3DDebugDrawer.h(37): fatal error C1083: Cannot open include file: 'bullet/LinearMath/btIDebugDraw.h': No such file or directory (s:\dd\feature\winc\src\vctools\compiler\cxxfe\sl\p1\c\p0prepro.c:1654) [D:\Cocos2dx\build_x86\cocos\cocos2dInternal.vcxproj]
     D:\Cocos2dx\src\cocos\physics3d/CCPhysics3DDebugDrawer.h(37): fatal error C1083: Cannot open include file: 'bullet/LinearMath/btIDebugDraw.h': No such file or directory (s:\dd\feature\winc\src\vctools\compiler\cxxfe\sl\p1\c\p0prepro.c:1654) [D:\Cocos2dx\build_x86\cocos\cocos2dInternal.vcxproj]
     D:\Cocos2dx\src\cocos\physics3d/CCPhysics3DDebugDrawer.h(37): fatal error C1083: Cannot open include file: 'bullet/LinearMath/btIDebugDraw.h': No such file or directory (s:\dd\feature\winc\src\vctools\compiler\cxxfe\sl\p1\c\p0prepro.c:1654) [D:\Cocos2dx\build_x86\cocos\cocos2dInternal.vcxproj]
     D:\Cocos2dx\src\cocos\physics3d/CCPhysics3DDebugDrawer.h(37): fatal error C1083: Cannot open include file: 'bullet/LinearMath/btIDebugDraw.h': No such file or directory (s:\dd\feature\winc\src\vctools\compiler\cxxfe\sl\p1\c\p0prepro.c:1654) [D:\Cocos2dx\build_x86\cocos\cocos2dInternal.vcxproj]
     D:\Cocos2dx\src\cocos\physics3d/CCPhysics3DDebugDrawer.h(37): fatal error C1083: Cannot open include file: 'bullet/LinearMath/btIDebugDraw.h': No such file or directory (s:\dd\feature\winc\src\vctools\compiler\cxxfe\sl\p1\c\p0prepro.c:1654) [D:\Cocos2dx\build_x86\cocos\cocos2dInternal.vcxproj]
glennerichall commented 6 years ago

I changed the CocosUsePrebuiltLibs.cmake file this way at https://github.com/cocos2d/cocos2d-x/blob/42c2ff27e097e25879f38174cfd0b431ae85f9ec/cmake/Modules/CocosUsePrebuiltLibs.cmake#L20

if(WINDOWS)
  if (${MSVC_VERSION} EQUAL 1900 OR ${MSVC_VERSION} GREATER 1900)
    set(_bullet_libs bullet libbullet-2015)
 else()
   set(_bullet_libs bullet libbullet)
 endif(${MSVC_VERSION})
else()
  # sequence is important
  set(_bullet_libs BulletDynamics libBulletDynamics BulletCollision libBulletCollision BulletMultiThreaded libBulletMultiThreaded LinearMath libLinearMath MiniCL libMiniCL)
endif(WINDOWS)

Change the line https://github.com/cocos2d/cocos2d-x/blob/42c2ff27e097e25879f38174cfd0b431ae85f9ec/cmake/Modules/CocosUsePrebuiltLibs.cmake#L206

to ${_root}/prebuilt/${PLATFORM_FOLDER}/${CMAKE_BUILD_TYPE}-lib

And also changed folder names in external/bullet/prebuilt/win32/debug and release to debug-lib and release-lib

drelaptop commented 6 years ago

Now the cmake have support Windows MSVC compiler, you can have a try using GitHub latest code(https://github.com/cocos2d/cocos2d-x/commit/4675ee79cd134ca63c8fd258c4e8a49f14fe9639 and later)

please close this issue @minggo