Recompile nagios plugin

I am new to the forum and i now started using Nagios. I edited one plugin and when i try to compile it i have the following message

gcc -o check_dig check_dig.c
In file included from check_dig.c:43:
common.h:37:20: error: config.h: No such file or directory
common.h:113:21: error: dirname.h: No such file or directory
common.h:198:21: error: gettext.h: No such file or directory
In file included from netutils.h:38,
from check_dig.c:44:
utils.h:17:24: error: utils_base.h: No such file or directory
In file included from netutils.h:38,
from check_dig.c:44:
utils.h:42: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘timeout_alarm_handler’
utils.h:65: error: redefinition of ‘struct timeval’
utils.h:72: warning: ‘struct timezone’ declared inside parameter list
utils.h:72: warning: its scope is only this definition or declaration, which is probably not what you want
In file included from check_dig.c:44:
netutils.h:41:25: error: getaddrinfo.h: No such file or directory
In file included from check_dig.c:44:
netutils.h:51: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘socket_timeout_alarm_handler’
check_dig.c: In function ‘main’:
check_dig.c:79: error: ‘LC_ALL’ undeclared (first use in this function)
check_dig.c:79: error: (Each undeclared identifier is reported only once
check_dig.c:79: error: for each function it appears in.)
check_dig.c:84: error: ‘SIGALRM’ undeclared (first use in this function)
check_dig.c:84: error: ‘SIG_ERR’ undeclared (first use in this function)
check_dig.c:85: warning: incompatible implicit declaration of built-in function ‘gettext’
check_dig.c:95: error: ‘PATH_TO_DIG’ undeclared (first use in this function)
check_dig.c:117: warning: incompatible implicit declaration of built-in function ‘strstr’
check_dig.c:131: warning: incompatible implicit declaration of built-in function ‘strchr’
check_dig.c:155: warning: incompatible implicit declaration of built-in function ‘strchr’
check_dig.c: In function ‘process_arguments’:
check_dig.c:234: warning: incompatible implicit declaration of built-in function ‘gettext’
check_dig.c:245: warning: incompatible implicit declaration of built-in function ‘gettext’
check_dig.c:253: warning: incompatible implicit declaration of built-in function ‘gettext’
check_dig.c:261: warning: incompatible implicit declaration of built-in function ‘gettext’
check_dig.c:265: warning: incompatible implicit declaration of built-in function ‘strdup’
check_dig.c:288: warning: incompatible implicit declaration of built-in function ‘strdup’
check_dig.c: In function ‘print_help’:
check_dig.c:320: warning: incompatible implicit declaration of built-in function ‘gettext’
check_dig.c: In function ‘print_usage’:
check_dig.c:364: warning: incompatible implicit declaration of built-in function ‘gettext’

how can i recompile it and make it work?

one more question is there somewhere any tutorial of explaining how some plugins work?

thanks in advance