简体   繁体   中英

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.

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?

This worked for me:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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