如何通过WSL为Windows平台编译Godot游戏引擎?
在WSL中编译Godot Windows版本的解决方案
问题场景
在Windows 10环境的WSL中编译带额外模块的Godot源码,安装SCons后执行命令:
scons platform=windows profile=custom.py
出现报错:
Invalid target platform "windows". The following platforms were detected: linuxbsd Please run SCons again and select a valid platform: platform=<string>
解决步骤
- 安装Windows交叉编译工具链
在Debian/Ubuntu系WSL发行版中执行以下命令:
sudo apt update sudo apt install mingw-w64
- 指定交叉编译工具链参数
修改SCons编译命令,明确指定Windows目标的编译工具:
# 编译64位Windows版本 scons platform=windows profile=custom.py CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ # 编译32位Windows版本 scons platform=windows profile=custom.py CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++
安装工具链后,SCons即可识别windows平台并完成交叉编译。
编辑补充:经提醒我发现这是Godot专属问题。我保留此问题供大家参考,也希望能帮到未来遇到相同问题的人。目前我仍不清楚原因,将前往Godot Game Engine Discord求助,若找到解决方案会在此更新。
补充说明:以上内容也是我本人所写,并非他人恶意留言。
内容的提问来源于stack exchange,提问作者GamEsnitzhel
相关产品推荐
相关产品推荐

