0 votes

Meticulously following the steps on building GDNative/CPP setup; have hit roadblock at the "Building C++ Bindings" step.

After inputting the scons platform=windows... command, the first thing command prompt prints seems to be what I want.

scons: Reading SConscript files ...

I looked up video tutorials on this process, and that is the first line they get, too. The problem comes in the second line:

IndexError: list index out of range:

It then proceeds to spit out a series of directories, which in-total comes out as follows:

scons: Reading SConscript files ...
IndexError: list index out of range:
  File "C:\Users\[MYUSERNAME]\Godot\[PROJECTNAME]\gdnative_cpp_example\godot-cpp\SConstruct", line 44:
    env = Environment()
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Environment.py", line 982:
    apply_tools(self, tools, toolpath)
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Environment.py", line 107:
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Environment.py", line 1789:
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Tool\__init__.py", line 296:
    self.generate(env, *args, **kw)
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Tool\default.py", line 40:
    for t in SCons.Tool.tool_list(env['PLATFORM'], env):
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Tool\__init__.py", line 1266:
    c_compiler = FindTool(c_compilers, env) or c_compilers[0]
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Tool\__init__.py", line 1169:
    if t.exists(env):
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Tool\msvc.py", line 292:
    return msvc_exists(env)
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Tool\MSCommon\vc.py", line 759:
    vcs = cached_get_installed_vcs(env)
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Tool\MSCommon\vc.py", line 524:
    ret = get_installed_vcs(env)
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Tool\MSCommon\vc.py", line 535:
    VC_DIR = find_vc_pdir(ver)
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Tool\MSCommon\vc.py", line 344:
    comps = find_vc_pdir_vswhere(msvc_version)
  File "c:\users\[MYUSERNAME]\appdata\local\programs\python\python37-32\lib\site-packages\scons\SCons\Tool\MSCommon\vc.py", line 306:
    vc_pdir = os.path.join(vsdir[0], 'VC')

I haven't found someone else with this problem, and so I did not find a way to learn what this list is, and what about my environment is causing it to go out of range.

Okay so after poking around at it for a while (with my fatally lackluster Python literacy), the problem line is right here:

vc_pdir = os.path.join(vsdir[0], 'VC')

So the problem is that this guy's vsdir is completely empty, hence the list being out-of-index. Here's the entire function for context:

def find_vc_pdir_vswhere(msvc_version):
Find the MSVC product directory using vswhere.exe.

Run it asking for specified version and get MSVS  install location
:param msvc_version:
:return: MSVC install dir or None

vswhere_path = os.path.join(
    'Program Files (x86)',
    'Microsoft Visual Studio',
vswhere_cmd = [vswhere_path, '-products', '*', '-version', msvc_version, '-property', 'installationPath']

if os.path.exists(vswhere_path):
    sp = subprocess.Popen(vswhere_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    vsdir, err = sp.communicate()
    vsdir = vsdir.decode("mbcs").splitlines()
    # vswhere could easily return multiple lines
    # we could define a way to pick the one we prefer, but since
    # this data is currently only used to make a check for existence,
    # returning the first hit should be good enough for now.
    vc_pdir = os.path.join(vsdir[0], 'VC')
    return vc_pdir
    # No vswhere on system, no install info available
    return None

The problems appear to begin here:

sp = subprocess.Popen(vswhere_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
vsdir, err = sp.communicate()

I experimentally tried print(sp.communicate()) and got back (b'', b'') in return. Pretty sure that's not right. I've whipped out the Python documentation to learn about subprocess. Maybe I'll figure out what's wrong before anyone reads this, idk.

Edit 2:
Cpp integration was a minor side project that (because of this roadblock) I have put on indefinite hold without any worry. I'm moving right on to my other Godot projects now, so no one ought feel obligated to help this problem if it would be any bother.

in Engine by (12 points)
edited by

Maybe could be worth reporting the issue on Github, that the sp.communicate() call to vswhere can return bad results in some cases?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.