VirusTotal / yara

The pattern matching swiss knife
https://virustotal.github.io/yara/
BSD 3-Clause "New" or "Revised" License
8.32k stars 1.45k forks source link

How to use jansson library inside custom module #2109

Closed sh4d0wlesss closed 1 month ago

sh4d0wlesss commented 2 months ago

Im trying to write a new module, i installed jansson lib and added header file to my module as #include <jansson.h>.

When i try to build yara with my module it gives this error:(i can run bootstrap and configure scripts without error)

make[1]: Entering directory '/home/sh4d0wless/Downloads/yara-4.5.0'
  CCLD     yara
/usr/bin/ld: ./.libs/libyara.so: undefined reference to `json_integer_value'
/usr/bin/ld: ./.libs/libyara.so: undefined reference to `json_array_size'
/usr/bin/ld: ./.libs/libyara.so: undefined reference to `json_string_value'
/usr/bin/ld: ./.libs/libyara.so: undefined reference to `json_loadb'
/usr/bin/ld: ./.libs/libyara.so: undefined reference to `json_array_get'
/usr/bin/ld: ./.libs/libyara.so: undefined reference to `json_delete'
/usr/bin/ld: ./.libs/libyara.so: undefined reference to `json_object_get'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:1746: yara] Error 1
make[1]: Leaving directory '/home/sh4d0wless/Downloads/yara-4.5.0'
make: *** [Makefile:1192: all] Error 2
sh4d0wlesss commented 2 months ago

i think i solved added this lines to configure.ac file

#-----------------------------------------------------------------------------
AC_CHECK_HEADERS([jansson.h],,
  AC_MSG_ERROR([please install Jansson library]))
AC_CHECK_LIB(jansson, json_loadb,,
  AC_MSG_ERROR([please install Jansson library]))

CFLAGS="$CFLAGS -DMY_MODULE"
PC_REQUIRES_PRIVATE="$PC_REQUIRES_PRIVATE jansson"

#-----------------------------------------------------------------------------
plusvic commented 1 month ago

Yes, that's correct.