diff --git a/CMakeLists.txt b/CMakeLists.txt
index 418e8eafd23e2f1405fa336e0d2f6133f8ec8e59..7bd43ae11299d44d9ef0da06bb42a344d288f70d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -106,8 +106,7 @@ target_link_libraries(json-validator
 
 target_link_libraries(json-validator
     PUBLIC
-    ${LIBUBOX_LIBRARIES})
-
+    libubox)
 # regex with boost if gcc < 4.9 - default is std::regex
 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
     if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9.0")
diff --git a/src/json-validator.cpp b/src/json-validator.cpp
index 1020272084ac147e24ae6cb16242eaece444a8a0..c6d3004ecac89d6c2ca7707e179b6dedf84ee864 100644
--- a/src/json-validator.cpp
+++ b/src/json-validator.cpp
@@ -1,7 +1,8 @@
 #include <iostream>
 #include <iomanip>
-#include <stdbool.h>
 
+extern "C"
+{
 #include <libubox/avl.h>
 #include <libubox/avl-cmp.h>
 #include <libubox/blobmsg.h>
@@ -11,8 +12,12 @@
 #include <glob.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <regex.h>
+#include <stdbool.h>
 
 #include <json-c/json.h>
+}
+
 #include <json-schema.hpp>
 #include <regex.h>