Search code examples
cmakeclionopensips

compiling Opensips on Clion: missing tap.h, which library is missing?


I am trying to compile Opensips on Clion as I want to debug and step through the code. I have tried adding environment variables through following lines in CMakeLists.txt:

set(CMAKE_C_FLAGS "-funroll-loops -Wcast-align -Wall -minline-all-stringops -falign-loops -ftree-vectorize -mtune=nocona -Wold-style-definition -Wmissing-field-initializers -Wredundant-decls" )

add_definitions(-DPKG_MALLOC -DSHM_MMAP -DUSE_MCAST -DDISABLE_NAGLE -DSTATISTICS -DHAVE_RESOLV_RES -DF_MALLOC -DF_MALLOC_OPTIMIZATIONS -DNAME='"opensips"' -DVERSION='"2.4.2"' -DARCH='"x86_64"' -DOS='"linux"' -DCOMPILER='"gcc 4.8.5"' -D__CPU_x86_64 -D__OS_linux -D__SMP_yes -DCFG_DIR='"/usr/local//etc/opensips/"' -DVERSIONTYPE='"git"' -DTHISREVISION='"c035556"' -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_EPOLL -DHAVE_SIGIO_RT -DHAVE_SELECT)

===========================================================

I get following errors and I am not sure which package is missing:

-- Build files have been written to: /root/opensips-2.4/cmake-build-debug [ 0%] Building C object CMakeFiles/opensips_2_4.dir/cachedb/test/test_backends.c.o [ 0%] Building C object CMakeFiles/opensips_2_4.dir/cachedb/example/example_cachedb.c.o /root/opensips-2.4/cachedb/test/test_backends.c:21:17: fatal error: tap.h: No such file or directory

include

^ compilation terminated. gmake[2]: * [CMakeFiles/opensips_2_4.dir/cachedb/test/test_backends.c.o] Error 1 gmake[2]: * Waiting for unfinished jobs.... /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: character constant too long for its type [enabled by default] MODULE_VERSION, ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: initialization makes pointer from integer without a cast [enabled by default] /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: (near initialization for ‘exports.version’) [enabled by default] In file included from /root/opensips-2.4/cachedb/example/../../sr_module.h:52:0, from /root/opensips-2.4/cachedb/example/example_cachedb.c:32: /root/opensips-2.4/cachedb/example/../../version.h:26:37: error: expected ‘}’ before string constant

define OPENSIPS_FULL_VERSION NAME " " VERSION " (" ARCH "/" OS ")"

^ /root/opensips-2.4/cachedb/example/../../sr_module.h:102:2: note: in expansion of macro ‘OPENSIPS_FULL_VERSION’ OPENSIPS_FULL_VERSION, ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: note: in expansion of macro ‘MODULE_VERSION’ MODULE_VERSION, ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: character constant too long for its type [enabled by default] /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: character constant too long for its type [enabled by default] /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: character constant too long for its type [enabled by default] /root/opensips-2.4/cachedb/example/example_cachedb.c:89:1: warning: missing initializer for field ‘compile_flags’ of ‘struct module_exports’ [-Wmissing-field-initializers] }; ^ In file included from /root/opensips-2.4/cachedb/example/example_cachedb.c:32:0: /root/opensips-2.4/cachedb/example/../../sr_module.h:175:8: note: ‘compile_flags’ declared here char compile_flags; /!< compile flags used on the module / ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:95:12: warning: ‘mod_init’ defined but not used [-Wunused-function] static int mod_init(void) ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:137:12: warning: ‘child_init’ defined but not used [-Wunused-function] static int child_init(int rank) ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:154:13: warning: ‘destroy’ defined but not used [-Wunused-function] static void destroy(void) ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:59:21: warning: ‘cmds’ defined but not used [-Wunused-variable] static cmd_export_t cmds[]= ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:65:23: warning: ‘params’ defined but not used [-Wunused-variable] static param_export_t params[]={ ^ gmake[2]: [CMakeFiles/opensips_2_4.dir/cachedb/example/example_cachedb.c.o] Error 1 gmake[1]: * [CMakeFiles/opensips_2_4.dir/all] Error 2 gmake: *** [all] Error 2


Solution

  • The tap.h error is due to the fact that you have enabled unit-testing support in your build, via the -DUNIT_TESTS flag in Makefile.conf. If you still want to go down this route and run the cachedb-related unit tests for MongoDB/Cassandra:

    • download libtap, from here
    • make and sudo make install