简体   繁体   English

如何使用 CMake 与 ntdll.lib 链接?

[英]How to link with ntdll.lib using CMake?

I am using ntdll.lib functions in my code to set the system timer to a higher resolution.我在代码中使用ntdll.lib函数将系统计时器设置为更高的分辨率。

But when I build my project I get this error:但是当我构建我的项目时,我收到了这个错误:

...
.../bin/ld.exe: ... undefined reference to `__imp_NtSetTimerResolution'
collect2.exe: error: ld returned 1 exit status
...

How do I tell the linker to link with ntdll.lib in my CMake?我如何告诉链接器与我的 CMake 中的ntdll.lib链接?

This worked for me:这对我有用:

if (WIN32)
    target_link_libraries(executable ntdll)
endif()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM