file_info_by_handle_class在Windows上编译V8时找不到
我正在 win10 pro 20H2 版本上编译 v8。
我已经获取了源代码 并使用 v8\src
目录下的 gn gen --ide=vs out\x64_proj
命令生成 Visual Studio 项目。
上述过程中存在一些小问题,例如环境变量、代理。但我修好了它们。
当我开始在 vs2019 中编译 gn_all 项目时,出现了一些错误。
它们中的大多数非常相似:
1>In file included from ../../../src/base/debug/stack_trace_win.cc:17:
1>In file included from D:\Windows Kits\10\Include\10.0.19041.0\um\windows.h:172:
1>In file included from D:\Windows Kits\10\Include\10.0.19041.0\um\winbase.h:43:
1>In file included from D:\Windows Kits\10\Include\10.0.19041.0\um\fileapifromapp.h:20:
1>D:\Windows Kits\10\Include\10.0.19041.0\um\winbase.h(9118,11): error : unknown type name 'FILE_INFO_BY_HANDLE_CLASS'
1> _In_ FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
^
我用谷歌搜索这个符号并在 minwinbase.h
中找到它:
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
typedef enum _FILE_INFO_BY_HANDLE_CLASS {
FileBasicInfo,
FileStandardInfo,
FileNameInfo,
FileRenameInfo,
FileDispositionInfo,
FileAllocationInfo,
FileEndOfFileInfo,
FileStreamInfo,
FileCompressionInfo,
FileAttributeTagInfo,
FileIdBothDirectoryInfo,
FileIdBothDirectoryRestartInfo,
FileIoPriorityHintInfo,
FileRemoteProtocolInfo,
FileFullDirectoryInfo,
FileFullDirectoryRestartInfo,
#if (NTDDI_VERSION >= NTDDI_WIN8)
FileStorageInfo,
FileAlignmentInfo,
FileIdInfo,
FileIdExtdDirectoryInfo,
FileIdExtdDirectoryRestartInfo,
#endif
#if (NTDDI_VERSION >= NTDDI_WIN10_RS1)
FileDispositionInfoEx,
FileRenameInfoEx,
#endif
#if (NTDDI_VERSION >= NTDDI_WIN10_19H1)
FileCaseSensitiveInfo,
FileNormalizedNameInfo,
#endif
MaximumFileInfoByHandleClass
} FILE_INFO_BY_HANDLE_CLASS, *PFILE_INFO_BY_HANDLE_CLASS;
#endif
我猜这是版本宏问题导致不包含此枚举。 因此我创建了另一个项目来打印 NTDDI_VERSION
,但它返回 0xa0000008
这比上面出现的所有宏都大。
然后我尝试将这些宏注释掉,它可以工作,而不是继续编译其他文件,并遇到一些新错误。
但显然这只是一个临时补丁,而不是根本原因,新的错误似乎也与此有关:
1>../../../src/base/debug/stack_trace_win.cc(173,12): error : use of undeclared identifier 'RtlCaptureStackBackTrace'
1> count_ = CaptureStackBackTrace(0, arraysize(trace_), trace_, nullptr);
1> ^
1>D:\Windows Kits\10\Include\10.0.19041.0\um\winbase.h(118,31): note: expanded from macro 'CaptureStackBackTrace'
1>#define CaptureStackBackTrace RtlCaptureStackBackTrace
1>../../../src/base/platform/platform-win32.cc(841,11): error : use of undeclared identifier 'IsWindows10OrGreater'
1> if (IsWindows10OrGreater())
我猜是一些构建工具没有正确配置,但我不知道它可能是什么。 有人有一些想法吗?
I am compiling v8 on win10 pro 20H2 build.
I had already fetch the source code
and used gn gen --ide=vs out\x64_proj
command under v8\src
directory to generate visual studio projects.
there are some small problems during process above,such as env variables, proxy. but I fixed them.
when I start to compile gn_all
project in my vs2019 , some error appeared.
most of them is very similar:
1>In file included from ../../../src/base/debug/stack_trace_win.cc:17:
1>In file included from D:\Windows Kits\10\Include\10.0.19041.0\um\windows.h:172:
1>In file included from D:\Windows Kits\10\Include\10.0.19041.0\um\winbase.h:43:
1>In file included from D:\Windows Kits\10\Include\10.0.19041.0\um\fileapifromapp.h:20:
1>D:\Windows Kits\10\Include\10.0.19041.0\um\winbase.h(9118,11): error : unknown type name 'FILE_INFO_BY_HANDLE_CLASS'
1> _In_ FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
^
I google this symbol and find it in minwinbase.h
:
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
typedef enum _FILE_INFO_BY_HANDLE_CLASS {
FileBasicInfo,
FileStandardInfo,
FileNameInfo,
FileRenameInfo,
FileDispositionInfo,
FileAllocationInfo,
FileEndOfFileInfo,
FileStreamInfo,
FileCompressionInfo,
FileAttributeTagInfo,
FileIdBothDirectoryInfo,
FileIdBothDirectoryRestartInfo,
FileIoPriorityHintInfo,
FileRemoteProtocolInfo,
FileFullDirectoryInfo,
FileFullDirectoryRestartInfo,
#if (NTDDI_VERSION >= NTDDI_WIN8)
FileStorageInfo,
FileAlignmentInfo,
FileIdInfo,
FileIdExtdDirectoryInfo,
FileIdExtdDirectoryRestartInfo,
#endif
#if (NTDDI_VERSION >= NTDDI_WIN10_RS1)
FileDispositionInfoEx,
FileRenameInfoEx,
#endif
#if (NTDDI_VERSION >= NTDDI_WIN10_19H1)
FileCaseSensitiveInfo,
FileNormalizedNameInfo,
#endif
MaximumFileInfoByHandleClass
} FILE_INFO_BY_HANDLE_CLASS, *PFILE_INFO_BY_HANDLE_CLASS;
#endif
I guess it was the version macro problem to cause this enum not included.
so I create another project to print NTDDI_VERSION
, but it return 0xa0000008
which is greater than all macro appear above.
then I try to just comment these macro out, and it works, vs continue to compile antother files, and meet some new errors.
but appearently this is just a temporary patch, not a root cause, and the new errors seems also have do with this:
1>../../../src/base/debug/stack_trace_win.cc(173,12): error : use of undeclared identifier 'RtlCaptureStackBackTrace'
1> count_ = CaptureStackBackTrace(0, arraysize(trace_), trace_, nullptr);
1> ^
1>D:\Windows Kits\10\Include\10.0.19041.0\um\winbase.h(118,31): note: expanded from macro 'CaptureStackBackTrace'
1>#define CaptureStackBackTrace RtlCaptureStackBackTrace
1>../../../src/base/platform/platform-win32.cc(841,11): error : use of undeclared identifier 'IsWindows10OrGreater'
1> if (IsWindows10OrGreater())
I guess it was that some buildtools didn't configure correctly, but I have no idea what it could be.
Anyone have some ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试安装 Windows sdk 版本 10.0.20348.0 或最新版本。
try install windows sdk version 10.0.20348.0 or newest.
我认为生成的VS项目文件足以浏览/编辑,但不适合编译。尝试在命令行上使用
ninja
进行构建。请参阅官方文档,简单来说就是:ninja -C out\x64_proj
,可选择构建特定目标。I think the generated VS project files are enough for browsing/editing but not suitable for compiling. Try building with
ninja
on the command line. See the official documentation, in short it's just:ninja -C out\x64_proj
, optionally with a specific target to build.这不是一个理想的解决方案,但它满足了我的即时需求。
将 v8 回滚到版本
9.9.115.10
并且 d8 构建正常。要回滚,
git checkout 7d7c04aac7d650964d96d1f1c080949ae5519c78
然后是
gclient 同步
。显然主分支目前已损坏。
This isn't an ideal solution but it met my immediate needs.
Roll v8 back to version
9.9.115.10
and d8 builds fine.To roll back,
git checkout 7d7c04aac7d650964d96d1f1c080949ae5519c78
and then
gclient sync
.Apparently the main branch is currently broken.
搜索您的所有项目“ _WIN32_WINNT”和“ WINVER”。将值更改为0x0A00
#define _WIN32_WINNT 0x0A00 //目标Windows 10
#Define Winver 0x0a00
此变量是您要构建的Windows的目标版本。因为您正在使用新版本的Visual Studio,但是您的软件随着旧版本要求运行。因此,您需要添加此。然后,编译器可以在Visual Studio中查找正确的库
Search all your project "_WIN32_WINNT" and "WINVER". Change the value to 0x0A00
#define _WIN32_WINNT 0x0A00 // Target Windows 10
#define WINVER 0x0A00
This variable is the target version for Windows you are plaining to build. Because the visual studio you are using having a new version but you software running with the old version requirement. So you need to add this. Then compiler can look up the correct library in Visual Studio