- 1 year ago
g++ cannot find reference to GetModuleInformation on Windows
If you're using the g++
compiler on Windows and encountering an error where it cannot find a reference to GetModuleInformation
, it indicates that the necessary Windows API declaration is missing.
To resolve this issue, you can manually declare the GetModuleInformation
function in your code by including the appropriate header and defining the function prototype. Here's an example of how you can do this:
cpp#include <windows.h>
#include <psapi.h> // Include the Psapi header for GetModuleInformation
// Declare the GetModuleInformation function manually
BOOL WINAPI GetModuleInformation(
HANDLE hProcess,
HMODULE hModule,
LPMODULEINFO lpmodinfo,
DWORD cb
);
int main() {
// Your code here
return 0;
}
In the above example, we include the windows.h
header for the necessary Windows API declarations and the psapi.h
header specifically for the GetModuleInformation
function.
By manually declaring the GetModuleInformation
function, you provide the necessary information to the g++
compiler, allowing it to resolve the reference correctly during the compilation process.
Make sure to adjust the rest of your code accordingly and include any other necessary headers or libraries for your application.