[英]g++ cannot find reference to GetModuleInformation on Windows
我正在 Windows (MinGW) 上編譯和鏈接 C++ 程序與 g++ 編譯命令如下所示:
g++ -c file.cpp -o file.o
鏈接命令如下所示:
g++ -L. -lPsapi -o file.exe file.o
我有一個名為Psapi.lib
的文件.
目錄(我從 Windows SKD 目錄中復制了它)但仍然找不到GetModuleInformation
的參考
PS.: GetModuleInformation Fails on Linkage in Windows 10沒有幫助
您很可能需要: (a) 定義PSAPI_VERSION
令牌(到1
); 或 (b) 通過其“新”名稱K32GetModuleInformation()
調用 function。
從文檔中:
如果 PSAPI_VERSION 為 2 或更大,則此 function 在 Psapi.h 中定義為 K32GetModuleInformation,並在 Kernel32.lib 和 Kernel32.dll 中導出。 如果 PSAPI_VERSION 為 1,則此 function 在 Psapi.h 中定義為 K32GetModuleInformation,並在 Psapi.lib 和 Psapi.dll 中作為調用 K32GetModuleInformation 的包裝器導出。
必須在 Windows 以及 Windows 7 及更高版本上運行的程序應始終將此 function 稱為 K32GetModuleInformation。 為確保正確解析符號,請將 Psapi.lib 添加到 TARGETLIBS 宏並使用 -DPSAPI_VERSION=1 編譯程序。 要使用運行時動態鏈接,請加載 Psapi.dll。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.