Hello I wanted to get the memory usage of a program (so i can for example detect memory leaks), but no matter what I do compiler throws:
undefined reference to `GetProcessMemoryInfo' collect2.exe: error: ld returned 1 exit status
I compile the program using batch file:
set FLAGS=-Wall -Wextra -g3 -O -Werror
set LINK=-static-libgcc -lpsapi -lkernel32
set SRC=*.c src/*.c test/*c
set OUT_FILE=-o build/build.exe
gcc %FLAGS% %LINK% %SRC% %OUT_FILE%
My code (simplified):
#include <windows.h>
#include <psapi.h>
#include <stdio.h>
int some_func_name()
{
PROCESS_MEMORY_COUNTERS pmc;
if ( !GetProcessMemoryInfo(GetCurrentProcess(),&pmc,sizeof(pmc)) ) { return 0; }
return 1;
}
Iv searched for similar problems but all of them are solved by including -lpsapi or -lkernel32 but in my case neither helps to solve this error. Would appreciate some help or explanation as to why my method doesn't work