0

I'm trying to implement this example process enumerator program from MSDN

I am getting numerous errors for unresolved symbols, including

undefined reference to `EnumProcessModules@16'

MSDN seems to have anticipated these issues and included some instructions in the comments, but I am unfamiliar with what they mean and how to implement them. Unfortunately, the MSDN page on TARGETLIBS is not very specific.

// To ensure correct resolution of symbols, add Psapi.lib to TARGETLIBS
// and compile with -DPSAPI_VERSION=1

How do I add Psapi.lib to TARGETLIBS? I've downloaded the Windows SDK and know the path to Psapi.lib on my computer (I actually seem to have 4 copies of it in the SDK folders, for different processor architectures). I also have a copy of psapi.a in my MinGW/lib folder.

Jonathan
  • 151
  • 5

1 Answers1

1

MinGW uses *.a files instead of *.lib files.

The equivalent of "psapi.lib" is "libpsapi.a"

This file should be in MinGW directory "MinGW\lib\libpsapi.a"

Right-click on project name. Go to:
C/C++ Build -> Settings
Add to Library

Your settings should look like the picture below. On my computer MinGW library is installed on "c:\MinGW\lib" but you may have a different location.

enter image description here

Barmak Shemirani
  • 30,904
  • 6
  • 40
  • 77
  • Thank you - I checked in my MinGW\lib folder and I do have "libpsapi.a" in there as well. So, I'm not sure why it's still not finding the library. I tried updating the include statement from #include to #include but am getting an error on the new include statement: fatal error: : No such file or directory. (I am very new to C++ as you can probably see!) – Jonathan Jan 15 '18 at 15:31
  • No, it's `#include ` in *.cpp file. That's for the compiler, don't touch that. Separately, you have add the library, that's for the linker. I added a picture for you. – Barmak Shemirani Jan 16 '18 at 00:40