Scons compilation problem with Visual studio (godot in Windows)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By arucardlestad
:warning: Old Version Published before Godot 3 was released.

Hi
I’m trying to compile godot in Windows following the instruction of Compiling for Windows — Godot Engine (latest) documentation in English
However I’m getting the following error

C:\godot>scons platform=windows scons: Reading SConscript files …

MSVC not detected, attempting MinGW.

  • gcc detected. ('translations: ', [‘C:\godot\editor/translations\ar.po’,
    ‘C:\godot\editor/translations\bg.po’, ‘C:\godot\editor/translations\bn.po’, ‘C:\godot\editor/translations\ca.po’, ‘C:\godot\editor/translations\cs.po’, ‘C:\godot\editor/translations\da.po’, ‘C:\godot\editor/translations\de.po’, ‘C:\godot\editor/translations\de_CH.po’, ‘C:\godot\editor/translations\el.po’, ‘C:\godot\editor/translations\es.po’, ‘C:\godot\editor/translations\es_AR.po’, ‘C:\godot\editor/translations\fa.po’, ‘C:\godot\editor/translations\fi.po’, ‘C:\godot\editor/translations\fr.po’, ‘C:\godot\editor/translations\hu.po’, ‘C:\godot\editor/translations\id.po’, ‘C:\godot\editor/translations\it.po’, ‘C:\godot\editor/translations\ja.po’, ‘C:\godot\editor/translations\ko.po’, ‘C:\godot\editor/translations\nb.po’, ‘C:\godot\editor/translations\nl.po’, ‘C:\godot\editor/translations\pl.po’, ‘C:\godot\editor/translations\pr.po’, ‘C:\godot\editor/translations\pt_BR.po’, ‘C:\godot\editor/translations\pt_PT.po’, ‘C:\godot\editor/translations\ru.po’, ‘C:\godot\editor/translations\sk.po’, ‘C:\godot\editor/translations\sl.po’, ‘C:\godot\editor/translations\th.po’, ‘C:\godot\editor/translations\tr.po’, ‘C:\godot\editor/translations\ur_PK.po’,
    ‘C:\godot\editor/translations\zh_CN.po’, ‘C:\godot\editor/translations\zh_HK.po’,
    ‘C:\godot\editor/translations\zh_TW.po’]) ('fonts: ',
    [‘C:\godot\editor/…/thirdparty/fonts\DroidSans.ttf’,
    ‘C:\godot\editor/…/thirdparty/fonts\DroidSansArabic.ttf’,
    ‘C:\godot\editor/…/thirdparty/fonts\DroidSansFallback.ttf’,
    ‘C:\godot\editor/…/thirdparty/fonts\DroidSansHebrew.ttf’,
    ‘C:\godot\editor/…/thirdparty/fonts\DroidSansJapanese.ttf’,
    ‘C:\godot\editor/…/thirdparty/fonts\DroidSansThai.ttf’,
    [‘C:\godot\editor/…/thirdparty/fonts\source_code_pro.otf’]])
    scons: done reading SConscript files. scons: Building targets …
    [Initial build] Compiling ==> platform\windows\os_windows.cpp
    ===== In file included from platform\windows\os_windows.cpp:41:0: platform\windows\joypad.h:35:20: fatal error: dinput.h: No such file
    or directory compilation terminated.

===== scons: *** [platform\windows\os_windows.windows.tools.64.o] Error 1 scons: building terminated because of errors.

I think the problem with
fatal error: dinput.h: No such file or directory
is a problem with the visual studio installation. I understand that I need to use visual studio 2015 (not 2017) I download visual studio 2015 from http://landinghub.visualstudio.com/visual-cpp-build-tools, but some of the files are missing from that visual studio option.
Or the problem could be that SCons is not able to locate environment variables of Visual C++.
Does anybody knows how to solve this problem?
Thanks
The objective of all this is to use godot from the Qt program

:bust_in_silhouette: Reply From: Calinou

Before compiling Godot using the Visual Studio C++ compiler, you need to initialize its environment variables. This can be done either by using the start menu entries created by Visual Studio, for example, by starting x64 Native Tools Command Prompt for VS 2017 (for Visual Studio 2017), navigating to the Godot source directory, then issuing the scons platform=windows command.

Alternatively, you can open a command prompt, then call a .bat file that will initialize the C++ compiler (the following commands are valid for 64-bit Windows installations, using the default Visual Studio path):

  • For Visual Studio 2017:
    call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=x64
  • For Visual Studio 2015:
    call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

Additionally, Godot can be compiled with either MSVC 2017 or MSVC 2015, both are supported (I’ve been using MSVC 2017 for a few months now, and it compiles Godot just fine). Also, Visual Studio 2017 does have an option to install only the C++ tools, as part of the default installer (it’s no longer a separate download).

This…

call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=x64

Needs to go into the docs.

dynamite-ready | 2018-01-13 17:33

I have tried exactly what you have suggested and I get this error “file: ‘gdnative/string.h’”

Any idea how to fix this @calinou?

Joe0239 | 2018-01-14 23:46