Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GetProcessImageFileName not linking

Im trying to use GetProcessImageFileName. I have included Psapi.h but when i try ti compile i get

error LNK2019: unresolved external symbol _GetProcessImageFileNameA@12 referenced in function "bool __cdecl FindProcesses(char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?FindProcesses@@YA_NPBDPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)99>G:\Test\main\Tests.exe : fatal error LNK1120: 1 unresolved externals

The function comes up in Itellisense so can anyone tell me why it wont compile?

like image 735
discodowney Avatar asked Sep 17 '12 15:09

discodowney


1 Answers

This is a linker failure (it does compile) and is unrelated to the inclusion of Psapi.h. You probably need to link with Psapi.lib.

For specific instructions on what library to link with see the Library section from the GetProcessImageFileName() reference page:

Kernel32.lib on Windows 7 and Windows Server 2008 R2; 
Psapi.lib (if PSAPI_VERSION=1) on Windows 7 and Windows Server 2008 R2; 
Psapi.lib on Windows Server 2008, Windows Vista, Windows Server 2003,
and Windows XP
like image 95
hmjd Avatar answered Nov 09 '22 20:11

hmjd