vislee / ngx_http_ipdb_module

Another nginx http geoip module by ipdb
GNU General Public License v2.0
117 stars 15 forks source link

alpinelinux环境下编译出错 #6

Open sanqi opened 4 years ago

sanqi commented 4 years ago

提示错误 ./ngx_http_ipdb_module-master//ipdb/ipdb.c In file included from ./ngx_http_ipdb_module-master//ipdb/ipdb.c:9: ./ngx_http_ipdb_module-master//ipdb/ipdb.h:60:44: error: unknown type name 'u_char' int ipdb_search(ipdb_reader *reader, const u_char *ip, int bit_count, int *node); ^~~~~~ ./ngx_http_ipdb_module-master//ipdb/ipdb.c:184:44: error: unknown type name 'u_char' int ipdb_search(ipdb_reader *reader, const u_char *ip, int bit_count, int *node) { ^~~~~~ ./ngx_http_ipdb_module-master//ipdb/ipdb.c: In function 'ipdb_find0': ./ngx_http_ipdb_module-master//ipdb/ipdb.c:219:42: error: unknown type name 'u_char' err = ipdb_search(reader, (const u_char *) &addr4.s_addr, 32, &node); ^~~~~~ ./ngx_http_ipdb_module-master//ipdb/ipdb.c:227:42: error: unknown type name 'u_char' err = ipdb_search(reader, (const u_char *) &addr6.s6_addr, 128, &node); ^~~~~~ make[1]: *** [objs/Makefile:1212: objs/addon/ipdb/ipdb.o] Error 1 make[1]: Leaving directory '/tmp/nginx-1.17.4' make: *** [Makefile:8: build] Error 2

在 ipdb.h里加上 typedef unsigned char u_char; 才能编译通过

xiaoyawl commented 3 years ago

在 ipdb.h里加上 typedef unsigned char u_char; 编译也不能过

不知道还能不能得到作者的更新

peytonyip commented 3 years ago

@xiaoyawl 在 ipdb.h 加的位置是在 ipdb_reader;int ipdb_reader_new(const char *file, ipdb_reader **reader); 之间,试了可以编译,你可以再试试,确保 alpine 装了 json-c-dev,修改后大概是这样:

typedef struct ipdb_reader {
    ipdb_meta_data *meta;
    int v4offset;
    int file_size;
    int data_size;
    unsigned char *data;
} ipdb_reader;

typedef unsigned char u_char;

int ipdb_reader_new(const char *file, ipdb_reader **reader);