在windows 10 上用ninja编译gn构建工具时编译器遇到C4819

在windows 10 上用ninja编译gn构建工具时编译器遇到C4819,第1张

在windows 10 上用ninja编译gn构建工具时编译器遇到C4819

问题发现经过
平台:Windows10 LTSC,VS2017,python3.9

F:programgit> git clone https://bitbucket.org/chromiumembedded/cef/src/master/ gn
F:programgit> cd gn
F:programgitgn> python build/gen.py
F:programgitgn> vcvarsall x64
**********************************************************************
** Visual Studio 2017 Developer Command prompt v15.9.21
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
F:programgitgn> ninja -C out
[51/284] CXX src/gn/command_help.obj
FAILED: src/gn/command_help.obj
ninja -t msvc -- cl.exe /nologo /showIncludes /FC -I..src -I. /O2 /DNDEBUG /Zc:inline /DNOMINMAX /DUNICODE /DWIN32_LEAN_AND_MEAN /DWINVER=0x0A00 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_UNICODE /D_WIN32_WINNT=0x0A00 /FS /W4 /WX /Zi /wd4099 /wd4100 /wd4127 /wd4244 /wd4267 /wd4505 /wd4838 /wd4996 /std:c++17 /GR- /D_HAS_EXCEPTIONS=0 /c ..srcgncommand_help.cc /Fosrc/gn/command_help.obj
f:programgitgnsrcgnescape.h: error C2220: warning treated as error - no 'object' file generated
f:programgitgnsrcgnescape.h: warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss

解决方法
修改gn/build/gen.py 第525行:
修改前

        '/wd4244',
        '/wd4267',
        '/wd4505',
        '/wd4838',
        '/wd4996',
        '/std:c++17',
        '/GR-',
        '/D_HAS_EXCEPTIONS=0',
    ])

添加一个’/wd4819’,

        '/wd4244',
        '/wd4267',
        '/wd4505',
        '/wd4838',
        '/wd4819',
        '/wd4996',
        '/std:c++17',
        '/GR-',
        '/D_HAS_EXCEPTIONS=0',
    ])

之后删除 out/src 文件,重新ninja -C out ,成功

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5701345.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存