Cross compiling for Windows from MacOS broken?

doubtfulgamesdoubtfulgames Posts: 2Member

Hi everyone!

I've been trying for the last week to create my own export templates for Windows, from MacOS, and I can't seem to figure out how to make it work. I have followed all of the instructions in the official documentation to the letter. I have updated Scons, updated Python, updated MinGW, installed yasm. I even tried downgrading MinGW to a previous version (that was a huge headache), that didn't help anything either.

I have also tried building several different versions of Godot: 3.1.1-stable is the one I want, but I've also tried 3.0-stable, 3.0.6-stable, 3.1-stable... I get slightly different errors from each, but none of them compile properly.

I've also tried building both 32 and 64 bit versions, neither of them work.

The error I've seen the most frequently is this one:

platform/windows/os_windows.cpp:3015:2: error: 'wcscpy_s' was not declared in this scope; did you mean 'wcscpy'?
 3015 |  wcscpy_s(from, p_path.length() + 1, p_path.c_str());
      |  ^~~~~~~~
      |  wcscpy
scons: *** [platform/windows/os_windows.windows.opt.debug.64.o] Error 1
scons: building terminated because of errors.

But honestly I feel like the code isn't at fault: I probably have the wrong version of something in my build process, but I've tried many different versions and had no success, so I thought I would ask here.

Any advice would be appreciated! Has anyone here successfully built a Windows version of Godot from MacOS? If so, what versions of all the things were you using? Is there anything not in the documentation that I need to know?

Thank you!


Tags :

Answers

  • MegalomaniakMegalomaniak Posts: 1,627Admin
    edited August 15

    This is probably not much help, but a quick google search found me this:

    I believe the "safe" versions of C library functions (the ones ending in _s) are a Microsoft extension. They are not present in the standard C library, so you can only use them if you use Microsoft's compilers (Visual C++/Visual Studio).

    http://forums.codeguru.com/showthread.php?478027-strcpy_s&p=1846795#post1846795

    Note that the post is from 2009 so I'm not sure how applicable that still is.

    edit: Also, can you provide exactly the line you use to try and build, might be you are just missing an argument or something.

  • doubtfulgamesdoubtfulgames Posts: 2Member
    edited August 15

    Sure @Megalomaniak ! I've tried a lot of different variations on the build command, but this is the main one I've been using:

    scons platform=windows tools=no target=release_debug bits=64

    Seems the most likely to work, since I'm removing a bunch of functionality with tools=no and target=release_debug. I also chose 64bit because I've seen fewer reports of problems building the 64bit version.

    Here is the full log in case it's helpful, it fails pretty quickly:

    » scons platform=windows tools=no target=release_debug bits=64
    scons: Reading SConscript files ...
    Configuring for Windows: target=release_debug, bits=64
    Using Mingw
    Checking for C header file mntent.h... (cached) no
    scons: done reading SConscript files.
    scons: Building targets ...
    [  4%] Compiling ==> platform/windows/os_windows.cpp
    platform/windows/os_windows.cpp: In member function 'virtual void OS_Windows::set_window_size(Size2)':
    platform/windows/os_windows.cpp:1815:8: warning: declaration of 'rect' shadows a previous local [-Wshadow=local]
     1815 |   RECT rect;
          |        ^~~~
    platform/windows/os_windows.cpp:1800:7: note: shadowed declaration is here
     1800 |  RECT rect;
          |       ^~~~
    platform/windows/os_windows.cpp: In member function 'virtual uint64_t OS_Windows::get_unix_time() const':
    platform/windows/os_windows.cpp:2192:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     2192 |  return (*(uint64_t *)&ft - *(uint64_t *)&fep) / 10000000;
          |           ^~~~~~~~~~~~~~~
    platform/windows/os_windows.cpp:2192:30: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     2192 |  return (*(uint64_t *)&ft - *(uint64_t *)&fep) / 10000000;
          |                              ^~~~~~~~~~~~~~~~
    platform/windows/os_windows.cpp: In member function 'virtual Error OS_Windows::execute(const String&, const List<String>&, bool, OS::ProcessID*, String*, int*, bool)':
    platform/windows/os_windows.cpp:2513:9: warning: declaration of 'ret' shadows a previous local [-Wshadow=local]
     2513 |   DWORD ret = WaitForSingleObject(pi.pi.hProcess, INFINITE);
          |         ^~~
    platform/windows/os_windows.cpp:2508:6: note: shadowed declaration is here
     2508 |  int ret = CreateProcessW(NULL, modstr.ptrw(), NULL, NULL, 0, NORMAL_PRIORITY_CLASS, NULL, NULL, si_w, &pi.pi);
          |      ^~~
    platform/windows/os_windows.cpp: In member function 'virtual Error OS_Windows::move_to_trash(const String&)':
    platform/windows/os_windows.cpp:3015:2: error: 'wcscpy_s' was not declared in this scope; did you mean 'wcscpy'?
     3015 |  wcscpy_s(from, p_path.length() + 1, p_path.c_str());
          |  ^~~~~~~~
          |  wcscpy
    scons: *** [platform/windows/os_windows.windows.opt.debug.64.o] Error 1
    scons: building terminated because of errors.
    
  • MegalomaniakMegalomaniak Posts: 1,627Admin
    edited August 15

    hmm, looking at the troubleshooting section, it mentions that on ubuntu distribution there are issues that are solved by switching to a mingw build with posix threading, considering that mac os is also a posix system, might have the same or at least a similar problem?

    https://godot.readthedocs.io/en/3.1/development/compiling/compiling_for_windows.html#troubleshooting

    a buildscript for mingw from around 2015(yeah, old, I know) and specifically to a comment to the gist that mentions how to make use of sdt::threads over win32 by changing --enable-threads=win32 to --enable-threads=posix and recompiling gcc-core, mingw, gcc etc...

    https://gist.github.com/Drakulix/9881160#gistcomment-1548235

    Mind, I'm not sure that this is the solution to your problem.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file