在 Clion 上编译 Opensips:缺少 tap.h,缺少哪个库?

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

我正在尝试在 Clion 上编译 Opensips,因为我想调试和单步执行代码。我尝试通过 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)

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

我收到以下错误,我不确定缺少哪个包:

-- 构建文件已写入:/root/opensips-2.4/cmake-build-debug [ 0%] 构建 C 对象 CMakeFiles/opensips_2_4.dir/cachedb/test/test_backends.c.o [ 0%] 构建 C 对象 CMakeFiles/opensips_2_4.dir/cachedb/example/example_cachedb.c.o /root/opensips-2.4/cachedb/test/test_backends.c:21:17: 致命错误: tap.h: 没有那个文件或目录

包括

^ 编译终止。 gmake[2]: * [CMakeFiles/opensips_2_4.dir/cachedb/test/test_backends.c.o] 错误 1 gmake[2]: * 等待未完成的工作.... /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2:警告:字符常量与其类型相比太长 [默认启用] MODULE_VERSION, ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2:警告:初始化使指针来自没有转换的整数 [默认启用] /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: 警告:('exports.version' 接近初始化)[默认启用] 在 /root/opensips-2.4/cachedb/example/../../sr_module.h:52:0 包含的文件中, 来自 /root/opensips-2.4/cachedb/example/example_cachedb.c:32: /root/opensips-2.4/cachedb/example/../../version.h:26:37: 错误:字符串常量

前需要‘}’

定义OPENSIPS_FULL_VERSION名称“”版本“(”ARCH“/”OS“)”

^ /root/opensips-2.4/cachedb/example/../../sr_module.h:102:2: 注意:在宏“OPENSIPS_FULL_VERSION”的扩展中 OPENSIPS_FULL_VERSION, ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: 注意:在宏“MODULE_VERSION”的扩展中 MODULE_VERSION, ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2:警告:字符常量与其类型相比太长 [默认启用] /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2:警告:字符常量与其类型相比太长 [默认启用] /root/opensips-2.4/cachedb/example/example_cachedb.c:75:2:警告:字符常量与其类型相比太长 [默认启用] /root/opensips-2.4/cachedb/example/example_cachedb.c:89:1:警告:缺少“struct module_exports”字段“compile_flags”的初始值设定项 [-Wmissing-field-initializers] }; ^ 在 /root/opensips-2.4/cachedb/example/example_cachedb.c:32:0 包含的文件中: /root/opensips-2.4/cachedb/example/../../sr_module.h:175:8: 注意:这里声明了‘compile_flags’ 字符compile_flags; /!< 模块上使用的编译标志 / ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:95:12:警告:“mod_init”已定义但未使用 [-Wunused-function] 静态整数 mod_init(void) ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:137:12: 警告:“child_init”已定义但未使用 [-Wunused-function] static int child_init(int 排名) ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:154:13: 警告:'destroy' 已定义但未使用 [-Wunused-function] 静态无效销毁(无效) ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:59:21: 警告:“cmds”已定义但未使用 [-Wunused-variable] 静态 cmd_export_t cmds[]= ^ /root/opensips-2.4/cachedb/example/example_cachedb.c:65:23: 警告:'params' 已定义但未使用 [-Wunused-variable] 静态 param_export_t 参数[]={ ^ gmake[2]: [CMakeFiles/opensips_2_4.dir/cachedb/example/example_cachedb.c.o] 错误 1 gmake[1]: * [CMakeFiles/opensips_2_4.dir/all] 错误2 gmake: *** [所有] 错误 2

tap.h 错误是由于您通过 Makefile.conf 中的 -DUNIT_TESTS 标志在构建中启用了单元测试支持。如果你仍然想沿着这条路走下去 运行 与 cachedb 相关的单元测试 MongoDB/Cassandra:

  • here
  • 下载 libtap
  • makesudo make install