scons ParseConfig 在 Windows 上使用 wx-config 的行为不正确

scons ParseConfig behaving incorrectly with wx-config on windows

本文关键字:wx-config 不正确 ParseConfig Windows scons      更新时间:2023-10-16

我正在尝试使用MinGW在Windows上使用带有scons的wx-widgets。这是我的SConstruct的违规行:

env.ParseConfig("wx-config --cxxflags --libs")

在此之后,打印env['CPPPATH']立即给出:

['C:software_libwxWidgets2.8libgcc_dllmsw', 'C:software_libwxWidgets2.8include']

显然,这似乎缺少一些非常重要的斜杠。我认为这可能与 wx-config 的 windows 端口在其输出中给出反斜杠有关。

这些路径稍后会逐字传递给编译器,从而导致错误。其他一切都很好。

我该怎么做才能解决此问题?

用蛮力解决了这个问题。编写了一个由以下内容组成的帮助程序 python 脚本:

import subprocess, sys
p = subprocess.Popen(["wx-config", "--cxxflags", "--libs"], stdout=subprocess.PIPE)
out, err = p.communicate()
san = out.replace("\", "/")
sys.stdout.write(san)
sys.exit(0)

最后打电话

env.ParseConfig("python sanitize-wx-config.py")

在 SConscript 文件中。这解决了问题: