Bug #1671
closedCygwin Windows compilation with libjansson from source
Description
When compiling Suricata if - libjansson4/dev package is available on the system Suri will autodetect that and enable it (one can check with suricata--build-info)
Since there is no linjansson4 and libjansson-dev package readily available for Cygwin under windows - it can be manually compiled form source like so:
wget http://www.digip.org/jansson/releases/jansson-2.7.tar.gz tar xvf jansson-2.7.tar.gz && cd jansson-2.7 ./configure --prefix=/usr && make && make install
When installed - it seems we have all that is needed:
Administrator@WIN-5B0EU82E444 /tmp/oisf $ ls /usr/include/ |grep jansson jansson.h jansson_config.h Administrator@WIN-5B0EU82E444 /tmp/oisf $ ls /lib/ |grep jansson libjansson.a libjansson.dll.a libjansson.la Administrator@WIN-5B0EU82E444 /tmp/oisf
However compilation fails with the following:
In file included from output-json-alert.c:59:0: output-json-email-common.h:40:51: error: unknown type name ‘json_t’ TmEcode JsonEmailLogJson(JsonEmailLogThread *aft, json_t *js, const Packet *p, Flow *f, void *state, void *vtx, uint64_t tx_id); ^ In file included from output-json-alert.c:59:0: output-json-email-common.h:41:1: error: unknown type name ‘json_t’ json_t *JsonEmailAddMetadata(const Flow *f, uint32_t tx_id); ^ output-json-alert.c:107:41: error: unknown type name ‘json_t’ static void AlertJsonTls(const Flow *f, json_t *js) ^ output-json-alert.c:124:41: error: unknown type name ‘json_t’ static void AlertJsonSsh(const Flow *f, json_t *js) ^ output-json-alert.c:140:62: error: unknown type name ‘json_t’ void AlertJsonHeader(const Packet *p, const PacketAlert *pa, json_t *js) ^ output-json-alert.c: In function ‘AlertJson’: output-json-alert.c:181:5: error: unknown type name ‘json_t’ json_t *hjs = NULL; ^ output-json-alert.c:188:5: error: unknown type name ‘json_t’ json_t *js = CreateJSONHeader((Packet *)p, 0, "alert"); ^ output-json-alert.c:201:9: error: implicit declaration of function ‘AlertJsonHeader’ [-Werror=implicit-function-declaration] AlertJsonHeader(p, pa, js); ^ output-json-alert.c:212:25: error: implicit declaration of function ‘json_object_set_new’ [-Werror=implicit-function-declaration] json_object_set_new(js, "http", hjs); ^ output-json-alert.c:226:21: error: implicit declaration of function ‘AlertJsonTls’ [-Werror=implicit-function-declaration] AlertJsonTls(p->flow, js); ^ output-json-alert.c:239:21: error: implicit declaration of function ‘AlertJsonSsh’ [-Werror=implicit-function-declaration] AlertJsonSsh(p->flow, js); ^ output-json-alert.c:299:21: error: implicit declaration of function ‘json_string’ [-Werror=implicit-function-declaration] json_object_set_new(js, "payload", json_string((char *)encoded)); ^ output-json-alert.c:330:13: error: implicit declaration of function ‘json_integer’ [-Werror=implicit-function-declaration] json_object_set_new(js, "stream", json_integer(stream)); ^ output-json-alert.c:364:25: error: implicit declaration of function ‘json_object_set’ [-Werror=implicit-function-declaration] json_object_set(js, "dest_ip", json_string(buffer)); ^ output-json-alert.c:372:9: error: implicit declaration of function ‘OutputJSONBuffer’ [-Werror=implicit-function-declaration] OutputJSONBuffer(js, aft->file_ctx, aft->json_buffer); ^ output-json-alert.c:373:9: error: implicit declaration of function ‘json_object_del’ [-Werror=implicit-function-declaration] json_object_del(js, "alert"); ^ output-json-alert.c:375:5: error: implicit declaration of function ‘json_object_clear’ [-Werror=implicit-function-declaration] json_object_clear(js); ^ output-json-alert.c:376:5: error: implicit declaration of function ‘json_decref’ [-Werror=implicit-function-declaration] json_decref(js); ^ output-json-alert.c: In function ‘AlertJsonDecoderEvent’: output-json-alert.c:386:5: error: unknown type name ‘json_t’ json_t *js; ^ output-json-alert.c:411:9: error: implicit declaration of function ‘json_object’ [-Werror=implicit-function-declaration] js = json_object(); ^ output-json-alert.c:411:12: warning: assignment makes pointer from integer without a cast js = json_object(); ^ output-json-alert.c:415:9: error: unknown type name ‘json_t’ json_t *ajs = json_object(); ^ output-json-alert.c:415:23: warning: initialization makes pointer from integer without a cast json_t *ajs = json_object(); ^ cc1: some warnings being treated as errors Makefile:1504: recipe for target 'output-json-alert.o' failed make[3]: *** [output-json-alert.o] Error 1 make[3]: Leaving directory '/tmp/oisf/src' Makefile:1007: recipe for target 'all' failed make[2]: *** [all] Error 2 make[2]: Leaving directory '/tmp/oisf/src' Makefile:458: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/tmp/oisf' Makefile:387: recipe for target 'all' failed make: *** [all] Error 2
This could be also referred -
https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Unix_Socket#Adding-a-regular-command
NOTE:
Cygwin comes with the following C JSON libraries instead -
libjson-c-devel
libjson-c-common
libjson-c2
Can those be potentially used instead in the case of compilation under Cygwin on Windows?
Files