Compile check_dummy on linux

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
ScareCrow57
Posts: 4
Joined: Tue Apr 24, 2012 6:45 am

Compile check_dummy on linux

Post by ScareCrow57 »

I am attempting to write my own plugin. As part of the exercise I want to compile the check_dummy plugin to make sure I can at least compile this. I am using cmake to create the make file. I have included the directories to the .h files supplied. When I run make I get the following

[100%] Building C object CMakeFiles/test-dummy.dir/check_dummy.c.o
In file included from /home/user-name/oracle/check_dummy.c:36:
/downloads/nagios-plugins-1.4.16/plugins/utils.h:39: error: ‘STATE_CRITICAL’ undeclared here (not in a function)
/downloads/nagios-plugins-1.4.16/plugins/utils.h:40: error: ‘DEFAULT_SOCKET_TIMEOUT’ undeclared here (not in a function)
/downloads/nagios-plugins-1.4.16/plugins/utils.h:41: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘timeout_alarm_handler’
/downloads/nagios-plugins-1.4.16/plugins/utils.h:71: warning: ‘struct timezone’ declared inside parameter list
/downloads/nagios-plugins-1.4.16/plugins/utils.h:71: warning: its scope is only this definition or declaration, which is probably not what you want
/home/user-name/oracle/check_dummy.c: In function ‘main’:
/home/user-name/oracle/check_dummy.c:45: error: ‘STATE_UNKNOWN’ undeclared (first use in this function)
/home/user-name/oracle/check_dummy.c:45: error: (Each undeclared identifier is reported only once
/home/user-name/oracle/check_dummy.c:45: error: for each function it appears in.)
/home/user-name/oracle/check_dummy.c:47: error: ‘LC_ALL’ undeclared (first use in this function)
/home/user-name/oracle/check_dummy.c:48: error: ‘PACKAGE’ undeclared (first use in this function)
/home/user-name/oracle/check_dummy.c:48: error: ‘LOCALEDIR’ undeclared (first use in this function)
/home/user-name/oracle/check_dummy.c:52: warning: passing argument 1 of ‘usage4’ makes pointer from integer without a cast
/data/SAN-VOL3/downloads/nagios-plugins-1.4.16/plugins/utils.h:91: note: expected ‘const char *’ but argument is of type ‘int’
/home/user-name/oracle/check_dummy.c:54: error: ‘NP_VERSION’ undeclared (first use in this function)
/home/user-name/oracle/check_dummy.c:55: warning: incompatible implicit declaration of built-in function ‘exit’
/home/user-name/oracle/check_dummy.c:55: error: ‘STATE_OK’ undeclared (first use in this function)
/home/user-name/oracle/check_dummy.c:59: warning: incompatible implicit declaration of built-in function ‘exit’
/home/user-name/oracle/check_dummy.c:62: warning: passing argument 1 of ‘usage4’ makes pointer from integer without a cast
/data/SAN-VOL3/downloads/nagios-plugins-1.4.16/plugins/utils.h:91: note: expected ‘const char *’ but argument is of type ‘int’
/home/user-name/oracle/check_dummy.c:68: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
/usr/include/stdio.h:361: note: expected ‘const char * __restrict__’ but argument is of type ‘int’
/home/user-name/oracle/check_dummy.c:70: error: ‘STATE_WARNING’ undeclared (first use in this function)
/home/user-name/oracle/check_dummy.c:71: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
/usr/include/stdio.h:361: note: expected ‘const char * __restrict__’ but argument is of type ‘int’
/home/user-name/oracle/check_dummy.c:74: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
/usr/include/stdio.h:361: note: expected ‘const char * __restrict__’ but argument is of type ‘int’
/home/user-name/oracle/check_dummy.c:77: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
/usr/include/stdio.h:361: note: expected ‘const char * __restrict__’ but argument is of type ‘int’
/home/user-name/oracle/check_dummy.c:80: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
/usr/include/stdio.h:361: note: expected ‘const char * __restrict__’ but argument is of type ‘int’
/home/user-name/oracle/check_dummy.c:82: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
/usr/include/stdio.h:361: note: expected ‘const char * __restrict__’ but argument is of type ‘int’
/home/user-name/oracle/check_dummy.c: In function ‘print_help’:
/home/user-name/oracle/check_dummy.c:99: error: ‘NP_VERSION’ undeclared (first use in this function)
/home/user-name/oracle/check_dummy.c:112: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
/usr/include/stdio.h:361: note: expected ‘const char * __restrict__’ but argument is of type ‘int’
/home/user-name/oracle/check_dummy.c:114: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast
/usr/include/stdio.h:361: note: expected ‘const char * __restrict__’ but argument is of type ‘int’
make[2]: *** [CMakeFiles/test-dummy.dir/check_dummy.c.o] Error 1
make[1]: *** [CMakeFiles/test-dummy.dir/all] Error 2
make: *** [all] Error 2

I suspect I ma missing a library or something. Any ideas on what is missing?
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Compile check_dummy on linux

Post by sreinhardt »

Could you post the exact make command that you are using? Chances are, as you thought, that you happen to be missing one or more files to be included.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
ScareCrow57
Posts: 4
Joined: Tue Apr 24, 2012 6:45 am

Re: Compile check_dummy on linux

Post by ScareCrow57 »

This is the CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

PROJECT(oracle C)
include_directories ("/data/SAN-VOL3/downloads/nagios/include/")
include_directories ("/data/SAN-VOL3/downloads/nagios-plugins-1.4.16/plugins/")
include_directories ("/data/SAN-VOL3/downloads/nagios-plugins-1.4.16/gl/")
include_directories ("/data/SAN-VOL3/downloads/nagios-plugins-1.4.16/lib/")


#ADD_DEFINITIONS(-g -O2 -fsigned-char -freg-struct-return -Wall -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Winline -Werror)
ADD_EXECUTABLE(test-dummy check_dummy.c)
TARGET_LINK_LIBRARIES(test-dummy -locilib)

Followed by the Makefile



# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target

#=============================================================================
# Special targets provided by cmake.

# Disable implicit rules so canonical targets will work.
.SUFFIXES:

# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =

.SUFFIXES: .hpux_make_needs_suffix_list

# Suppress display of executed commands.
$(VERBOSE).SILENT:

# A target that is always out of date.
cmake_force:
.PHONY : cmake_force

#=============================================================================
# Set environment variables for the build.

# The shell in which to execute make rules.
SHELL = /bin/sh

# The CMake executable.
CMAKE_COMMAND = /usr/local/bin/cmake

# The command to remove a file.
RM = /usr/local/bin/cmake -E remove -f

# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/user-name/oracle

# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/user-name/oracle

#=============================================================================
# Targets provided globally by CMake.

# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..."
/usr/local/bin/cmake -i .
.PHONY : edit_cache

# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast

# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/local/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache

# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast

# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /home/cdevoe/oracle/CMakeFiles /home/cdevoe/oracle/CMakeFiles/progress.marks
$(MAKE) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /home/cdevoe/oracle/CMakeFiles 0
.PHONY : all

# The main clean target
clean:
$(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean

# The main clean target
clean/fast: clean
.PHONY : clean/fast

# Prepare targets for installation.
preinstall: all
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall

# Prepare targets for installation.
preinstall/fast:
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast

# clear depends
depend:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend

#=============================================================================
# Target rules for targets named test-dummy

# Build rule for target.
test-dummy: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 test-dummy
.PHONY : test-dummy

# fast build rule for target.
test-dummy/fast:
$(MAKE) -f CMakeFiles/test-dummy.dir/build.make CMakeFiles/test-dummy.dir/build
.PHONY : test-dummy/fast

check_dummy.o: check_dummy.c.o
.PHONY : check_dummy.o

# target to build an object file
check_dummy.c.o:
$(MAKE) -f CMakeFiles/test-dummy.dir/build.make CMakeFiles/test-dummy.dir/check_dummy.c.o
.PHONY : check_dummy.c.o

check_dummy.i: check_dummy.c.i
.PHONY : check_dummy.i

# target to preprocess a source file
check_dummy.c.i:
$(MAKE) -f CMakeFiles/test-dummy.dir/build.make CMakeFiles/test-dummy.dir/check_dummy.c.i
.PHONY : check_dummy.c.i

check_dummy.s: check_dummy.c.s
.PHONY : check_dummy.s

# target to generate assembly for a file
check_dummy.c.s:
$(MAKE) -f CMakeFiles/test-dummy.dir/build.make CMakeFiles/test-dummy.dir/check_dummy.c.s
.PHONY : check_dummy.c.s

# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... edit_cache"
@echo "... rebuild_cache"
@echo "... test-dummy"
@echo "... check_dummy.o"
@echo "... check_dummy.i"
@echo "... check_dummy.s"
.PHONY : help



#=============================================================================
# Special targets to cleanup operation of make.

# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
Locked