Open domino540 opened 1 year ago
If you have pkg-config
installed can you give me the output of:
pkg-config --cflags --libs json-c
I don't have a Debian machine handy to test on at the moment.
Hi,
output of pkg-config --cflags --libs json-c
:
# pkg-config --cflags --libs json-c
-I/usr/include/json-c -ljson-c
Issue seems that in Debian, the header files of json-c are in /usr/include/json-c
. I tried to update the code like this:
diff --git a/src/check_rest_api.c b/src/check_rest_api.c
index 9c907d2..d19a363 100644
--- a/src/check_rest_api.c
+++ b/src/check_rest_api.c
@@ -2,9 +2,9 @@
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
-#include <json/json_tokener.h>
-#include <json/json_object.h>
-#include <json/json_util.h>
+#include <json-c/json_tokener.h>
+#include <json-c/json_object.h>
+#include <json-c/json_util.h>
#include "headers/check_rest_api.h"
#include "headers/read_input.h"
diff --git a/src/check_thresholds.c b/src/check_thresholds.c
index a23b6a8..59d28ca 100644
--- a/src/check_thresholds.c
+++ b/src/check_thresholds.c
@@ -4,9 +4,9 @@
#include <ctype.h>
#include <curl/curl.h>
-#include <json/json_tokener.h>
-#include <json/json_object.h>
-#include <json/json_util.h>
+#include <json-c/json_tokener.h>
+#include <json-c/json_object.h>
+#include <json-c/json_util.h>
#include "headers/check_rest_api.h"
#include "headers/read_input.h"
But when compiling it i get another error:
# make
gcc -c -o check_rest_api.o check_rest_api.c -Wall -Werror
gcc -c -o read_input.o read_input.c -Wall -Werror
gcc -o check_rest_api check_rest_api.o read_input.o check_thresholds.c -Wall -Werror -lcurl -ljson-c
/usr/bin/ld: read_input.o:(.bss+0x0): multiple definition of `argVals'; check_rest_api.o:(.bss+0x0): first defined here
/usr/bin/ld: /tmp/ccLzaMMq.o:(.bss+0x0): multiple definition of `argVals'; check_rest_api.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:11: check_rest_api] Error 1
Sine i have no c knowledge, i dotn know what the problem is :(
FWIW, I get the exact same compilation errors on Ubuntu 22.04.2 LTS using v1.2.0 or v1.2.1.
There are two issues mentioned here. Regarding the header files in the original comment:
I checked the current status on RHEL. On RHEL 9 it's the same as on Debian and Ubuntu: The header files are placed in /usr/include/json-c
and the code doesn't compile. Om RHEL 7 (soon to be EoL), they are located in /usr/include/json
, but then /usr/include/json-c
is created as a symlink. So I believe the includes in this repository can safely (and should) be changed from json
to json-c
by now.
Then there's the linking error, which is because argVals is definied in read_input.h
. It should instead be declared as extern struct
.
These commands make the required adjustments:
sed -i 's%^#include <json/%#include <json-c/%' *.c
sed -i 's%^struct%extern struct%' headers/read_input.h
All in all, I think this issue should be tagged as a bug, and the above changes made. (I don't believe a PR is called for here, but I can make one nonetheless if preferable.)
Debian 11
Hi,
I have problem with downloaded binary even with compiling source code.
Try to run compiled
Compiling error
Thank for help