Using NVML in C program

I am not able to use the NVML in C program.

Here is the error I get when I compile the below program.

[trainee3@blr-gpu2 trainee3]$gcc using_nvml.c -o using_nvml
using_nvml.c: In function ‘main’:
using_nvml.c:27: warning: incompatible implicit declaration of
built-in function ‘exit’
/tmp/ccm243VJ.o: In function main': using_nvml.c:(.text+0x28): undefined reference to nvmlInit’
using_nvml.c:(.text+0x39): undefined reference to nvmlErrorString' using_nvml.c:(.text+0x6c): undefined reference to nvmlDeviceGetCount’
collect2: ld returned 1 exit status

The program:

#include<stdio.h>
#include"nvml.h"
int main()
{
unsigned int deviceCount;
nvmlReturn_t result;
result = nvmlInit();

if (NVML_SUCCESS != result)
{
printf("Failed to initialize NVML: %s\n", nvmlErrorString(result));
printf("Press ENTER to continue…\n");
getchar();
return 1;
}

result = nvmlDeviceGetCount(&deviceCount);
if(NVML_SUCCESS != result)
{
printf("Failure\n");
exit(1);
}

printf("%u",deviceCount);
return 0;
}

Why am I getting this error? I actually want to write a C program to
check the GPU utilization. I wrote the above program for practice. Is
it an issue with the path of header file, ‘nvml.h’? ‘nvml.h’ is in the
same directory. I copied it from nvidia-ml perl binding directory (which I downloaded from CPAN)