Thread overview
Linkage problem
Nov 13, 2010
MRatcliff
Nov 26, 2010
Walter Bright
Nov 27, 2010
MRatcliff
November 13, 2010
I used implib to create a .lib file for psapi.dll. I also found a header file.

The header file contains an ifdef __cplusplus declaration so it appears the linkage should have C semantics.

The .lib file shows, among other entry points, the following (using libunres):

_EnumProcessModules
_EnumProcessModulesEx
_EnumProcesses
_GetDeviceDriverBaseNameA
_GetDeviceDriverBaseNameW
The 'EnumProcesses' is the function I am calling in a test application.  When
it links I get the following error:

OPTLINK (R) for Win32  Release 8.00.5
Copyright (C) Digital Mars 1989-2009  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
.\Obj\tproclist.obj(tproclist)
 Error 42: Symbol Undefined _EnumProcesses@12

How can I get this to resolve corrrectly?
November 26, 2010
MRatcliff wrote:
> I used implib to create a .lib file for psapi.dll. I also found a header file.
> 
> The header file contains an ifdef __cplusplus declaration so it appears the
> linkage should have C semantics.
> 
> The .lib file shows, among other entry points, the following (using libunres):
> 
> _EnumProcessModules
> _EnumProcessModulesEx
> _EnumProcesses
> _GetDeviceDriverBaseNameA
> _GetDeviceDriverBaseNameW
> The 'EnumProcesses' is the function I am calling in a test application.  When
> it links I get the following error:
> 
> OPTLINK (R) for Win32  Release 8.00.5
> Copyright (C) Digital Mars 1989-2009  All rights reserved.
> http://www.digitalmars.com/ctg/optlink.html
> .\Obj\tproclist.obj(tproclist)
>  Error 42: Symbol Undefined _EnumProcesses@12
> 
> How can I get this to resolve corrrectly?

The @12 means it is compiled using the stdcall calling convention, not the C++ calling convention.
November 27, 2010
Thanks -

Problem resolved by removing the WINAPI macro from the header file.

BOOL WINAPI EnumProcesses(DWORD *,DWORD,DWORD *);

To

BOOL EnumProcesses(DWORD *,DWORD,DWORD *);