1

我尝试使用 Visual Studio 构建lmdb,但出现以下错误:

mdb.obj:错误 LNK2001:未解析的外部符号 _NtMapViewOfSection@40
mdb.obj:错误 LNK2001:未解析的外部符号 _NtClose@4
mdb.obj:错误 LNK2001:未解析的外部符号 _NtCreateSection@28

在代码中首次使用此函数时,有以下注释:

/* We use native NT APIs to setup the memory map, so that we can
 * let the DB file grow incrementally instead of always preallocating
 * the full size. These APIs are defined in <wdm.h> and <ntifs.h>
 * but those headers are meant for driver-level development and
 * conflict with the regular user-level headers, so we explicitly
 * declare them here. Using these APIs also means we must link to
 * ntdll.dll, which is not linked by default in user code.
 */
NTSTATUS WINAPI
NtCreateSection(OUT PHANDLE sh, IN ACCESS_MASK acc,
  IN void * oa OPTIONAL,
  IN PLARGE_INTEGER ms OPTIONAL,
  IN ULONG pp, IN ULONG aa, IN HANDLE fh OPTIONAL);

我需要如何在 Visual Studio 中链接 ntdll.dll?我明白,这个问题很愚蠢,但我无法在几个小时内找到解决方案..

4

2 回答 2

2

您可以ntdll.lib在 Visual Studio 中链接。

于 2016-05-05T22:27:03.080 回答
0

非常感谢@datjko!他是对的:

我相信trunk中的版本号不是错误更新的。0.9.17 版本于 2015 年 11 月 30 日发布,可在此处获取 github.com/LMDB/lmdb/releases/tag/LMDB_0.9.17。据我所知,在 github.com/LMDB/lmdb/commit/... 发布后,ntdll 中的函数的使用被添加到主干中。所以,除非你想试驾最近的开发版本,否则我相信你最好使用最近的稳定版本。

听从他的建议后,问题就解决了。

于 2016-05-11T09:05:50.513 回答