Linker error: LNK2001 with GetModuleBaseName and EnumProcessModule
-
Hello, I'm trying to use GetModuleBaseName and EnumProcessModules, but I'm doing something wrong because I get linker error 2001. I guess that the problem is with WINAPI. I have a .c file that is forced to be compiled as c++ and I call those functions from there like this: EnumProcessModules(hProc, &hMod, sizeof(hMod), &cbNeeded); GetModuleBaseName(hProc, hMod, pParentName, sizeof(pParentName)); Then I'm using PSAPI.h where I have -- clip -- #ifdef __cplusplus extern "C" { #endif -- clip -- BOOL WINAPI EnumProcesses( DWORD * lpidProcess, DWORD cb, DWORD * cbNeeded ); -- clip -- DWORD WINAPI GetModuleBaseNameA( HANDLE hProcess, HMODULE hModule, LPSTR lpBaseName, DWORD nSize ); DWORD WINAPI GetModuleBaseNameW( HANDLE hProcess, HMODULE hModule, LPWSTR lpBaseName, DWORD nSize ); #ifdef UNICODE #define GetModuleBaseName GetModuleBaseNameW #else #define GetModuleBaseName GetModuleBaseNameA #endif // !UNICODE -- clip -- #ifdef __cplusplus } #endif -- clip -- Now I get: myprogram.obj : error LNK2001: unresolved external symbol _GetModuleBaseNameA@16 myprogram.obj : error LNK2001: unresolved external symbol _EnumProcessModules@16 Why? :confused: I've read many examples and it seems to me that I'm doing this in the same way as they do. I would be glad if someone helped me with this.:) -Janetta
-
Hello, I'm trying to use GetModuleBaseName and EnumProcessModules, but I'm doing something wrong because I get linker error 2001. I guess that the problem is with WINAPI. I have a .c file that is forced to be compiled as c++ and I call those functions from there like this: EnumProcessModules(hProc, &hMod, sizeof(hMod), &cbNeeded); GetModuleBaseName(hProc, hMod, pParentName, sizeof(pParentName)); Then I'm using PSAPI.h where I have -- clip -- #ifdef __cplusplus extern "C" { #endif -- clip -- BOOL WINAPI EnumProcesses( DWORD * lpidProcess, DWORD cb, DWORD * cbNeeded ); -- clip -- DWORD WINAPI GetModuleBaseNameA( HANDLE hProcess, HMODULE hModule, LPSTR lpBaseName, DWORD nSize ); DWORD WINAPI GetModuleBaseNameW( HANDLE hProcess, HMODULE hModule, LPWSTR lpBaseName, DWORD nSize ); #ifdef UNICODE #define GetModuleBaseName GetModuleBaseNameW #else #define GetModuleBaseName GetModuleBaseNameA #endif // !UNICODE -- clip -- #ifdef __cplusplus } #endif -- clip -- Now I get: myprogram.obj : error LNK2001: unresolved external symbol _GetModuleBaseNameA@16 myprogram.obj : error LNK2001: unresolved external symbol _EnumProcessModules@16 Why? :confused: I've read many examples and it seems to me that I'm doing this in the same way as they do. I would be glad if someone helped me with this.:) -Janetta
Ok, it is a linker error ! Come on, its the most common of the linker errors !. You forgot to include the psapi.lib in your linker tab.
-
Ok, it is a linker error ! Come on, its the most common of the linker errors !. You forgot to include the psapi.lib in your linker tab.