1

I'm trying to include psapi.h in a Code::Blocks C++ console project, but it does not allow me to use it. From the informations I've been able to gather in 3 hours of googling, I need to include a Library(it seems to be psapi.lib) in the project by going on build options->Linker settings and add either psapi.h or psapi.lib(different sources gave me different indications). I've tried to do so, and it does nothing.

It is the first time I try to include a library, so it may be my fault.

It would be perfect if someone could give me some steps to follow from the point in which you create a project to adding the library, to be sure I haven't missed out anything during project creation or later.

I've been asked for a minimal reproducible example. I'm not sure if this satisfies the condition, but it is enough for the problem I'm asking about to manifest

#include <psapi.h>  
int main()
{
return 0;
}
t.niese
  • 39,256
  • 9
  • 74
  • 101
David
  • 123
  • 1
  • 10
  • 4
    `#include ` 1st – Richard Critten Dec 08 '19 at 01:16
  • You also need to set up Code::Blocks compilation and build settings, so the compiler looks in the directory that contains the header(s) you're using, and the linker looks in the directory that contains the library. – Peter Dec 08 '19 at 01:17
  • I've added the example i've been requested to. The code I've seen on youtube worked without the need of using #include How can I set up the compilation and build settings? As far as I know, psapi.h should be included with codeblocks already. Is there a path I have to select? – David Dec 08 '19 at 01:25
  • 1
    You apparently [need to include](https://stackoverflow.com/questions/52367594/why-does-changing-the-order-of-including-psapi-h-gives-compilation-errosindent) `windows.h` before `psapi.h`. It is possible the video didn't show you everything. – 1201ProgramAlarm Dec 08 '19 at 02:17
  • Yeah I've tried to do that and change some linker settings and now it works! Very strange, I'm 100% sure the video don't have it, and it shows all the code. Still, the most important thing is that it now works! Thank you! And sorry to Richard Critten, I've tried what he said but including windows.h AFTER psapi.h. My fault! – David Dec 08 '19 at 02:22
  • 2
    Never add `-SOLVED-` to the title of the question. Either write an answer, if you think it will be helpful and accept it, otherwise, close or delete it. – t.niese Dec 08 '19 at 10:31

0 Answers0