error: 'res_ninit' was not declared in this scope; did you mean 'res_init'?
error: 'res_ninit' was not declared in this scope; did you mean 'res_init'?
我正在尝试从 alpine 中的源代码安装一个应用程序,它说没有 res_ninit
、res_nsearch
和 res_nclose
,但我们可以 see here Linux header 中确实存在并且我已经安装了 apk add linux-headers
,我该如何解决这个问题?
make install
Consolidate compiler generated dependencies of target save_linker_opts
[ 2%] Built target save_linker_opts
[ 2%] Built target build_protobuf
Consolidate compiler generated dependencies of target cdk_foundation
[ 3%] Building CXX object cdk/foundation/CMakeFiles/cdk_foundation.dir/socket_detail.cc.o
/dep/mysql-connector-cpp/cdk/foundation/socket_detail.cc: In function 'std::forward_list<cdk::foundation::connection::detail::Srv_host_detail> cdk::foundation::connection::detail::srv_list(const string&)':
/dep/mysql-connector-cpp/cdk/foundation/socket_detail.cc:1097:3: error: 'res_ninit' was not declared in this scope; did you mean 'res_init'?
1097 | res_ninit(&state);
| ^~~~~~~~~
| res_init
/dep/mysql-connector-cpp/cdk/foundation/socket_detail.cc:1107:13: error: 'res_nsearch' was not declared in this scope; did you mean 'res_search'?
1107 | int res = res_nsearch(&state, hostname.c_str(), ns_c_in, ns_t_srv, query_buffer, sizeof (query_buffer) );
| ^~~~~~~~~~~
| res_search
/dep/mysql-connector-cpp/cdk/foundation/socket_detail.cc:1143:3: error: 'res_nclose' was not declared in this scope
1143 | res_nclose(&state);
| ^~~~~~~~~~
make[2]: *** [cdk/foundation/CMakeFiles/cdk_foundation.dir/build.make:146: cdk/foundation/CMakeFiles/cdk_foundation.dir/socket_detail.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1061: cdk/foundation/CMakeFiles/cdk_foundation.dir/all] Error 2
更新: 我 cat header 文件 /usr/include/resolv.h
我们可以看到该函数不存在,所以问题是我该如何设置Linux header 喜欢ubuntu 可以在高山工作吗?
#ifndef _RESOLV_H
#define _RESOLV_H
#include <stdint.h>
#include <arpa/nameser.h>
#include <netinet/in.h>
#ifdef __cplusplus
extern "C" {
#endif
#define MAXNS 3
#define MAXDFLSRCH 3
#define MAXDNSRCH 6
#define LOCALDOMAINPARTS 2
#define RES_TIMEOUT 5
#define MAXRESOLVSORT 10
#define RES_MAXNDOTS 15
#define RES_MAXRETRANS 30
#define RES_MAXRETRY 5
#define RES_DFLRETRY 2
#define RES_MAXTIME 65535
/* unused; purely for broken apps */
typedef struct __res_state {
int retrans;
int retry;
unsigned long options;
int nscount;
struct sockaddr_in nsaddr_list[MAXNS];
# define nsaddr nsaddr_list[0]
unsigned short id;
char *dnsrch[MAXDNSRCH+1];
char defdname[256];
unsigned long pfcode;
unsigned ndots:4;
unsigned nsort:4;
unsigned ipv6_unavail:1;
unsigned unused:23;
struct {
struct in_addr addr;
uint32_t mask;
} sort_list[MAXRESOLVSORT];
void *qhook;
void *rhook;
int res_h_errno;
int _vcsock;
unsigned _flags;
union {
char pad[52];
struct {
uint16_t nscount;
uint16_t nsmap[MAXNS];
int nssocks[MAXNS];
uint16_t nscount6;
uint16_t nsinit;
struct sockaddr_in6 *nsaddrs[MAXNS];
unsigned int _initstamp[2];
} _ext;
} _u;
} *res_state;
#define __RES 19960801
#ifndef _PATH_RESCONF
#define _PATH_RESCONF "/etc/resolv.conf"
#endif
struct res_sym {
int number;
char *name;
char *humanname;
};
#define RES_F_VC 0x00000001
#define RES_F_CONN 0x00000002
#define RES_F_EDNS0ERR 0x00000004
#define RES_EXHAUSTIVE 0x00000001
#define RES_INIT 0x00000001
#define RES_DEBUG 0x00000002
#define RES_AAONLY 0x00000004
#define RES_USEVC 0x00000008
#define RES_PRIMARY 0x00000010
#define RES_IGNTC 0x00000020
#define RES_RECURSE 0x00000040
#define RES_DEFNAMES 0x00000080
#define RES_STAYOPEN 0x00000100
#define RES_DNSRCH 0x00000200
#define RES_INSECURE1 0x00000400
#define RES_INSECURE2 0x00000800
#define RES_NOALIASES 0x00001000
#define RES_USE_INET6 0x00002000
#define RES_ROTATE 0x00004000
#define RES_NOCHECKNAME 0x00008000
#define RES_KEEPTSIG 0x00010000
#define RES_BLAST 0x00020000
#define RES_USEBSTRING 0x00040000
#define RES_NOIP6DOTINT 0x00080000
#define RES_USE_EDNS0 0x00100000
#define RES_SNGLKUP 0x00200000
#define RES_SNGLKUPREOP 0x00400000
#define RES_USE_DNSSEC 0x00800000
#define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT)
#define RES_PRF_STATS 0x00000001
#define RES_PRF_UPDATE 0x00000002
#define RES_PRF_CLASS 0x00000004
#define RES_PRF_CMD 0x00000008
#define RES_PRF_QUES 0x00000010
#define RES_PRF_ANS 0x00000020
#define RES_PRF_AUTH 0x00000040
#define RES_PRF_ADD 0x00000080
#define RES_PRF_HEAD1 0x00000100
#define RES_PRF_HEAD2 0x00000200
#define RES_PRF_TTLID 0x00000400
#define RES_PRF_HEADX 0x00000800
#define RES_PRF_QUERY 0x00001000
#define RES_PRF_REPLY 0x00002000
#define RES_PRF_INIT 0x00004000
struct __res_state *__res_state(void);
#define _res (*__res_state())
int res_init(void);
int res_query(const char *, int, int, unsigned char *, int);
int res_querydomain(const char *, const char *, int, int, unsigned char *, int);
int res_search(const char *, int, int, unsigned char *, int);
int res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int);
int res_send(const unsigned char *, int, unsigned char *, int);
int dn_comp(const char *, unsigned char *, int, unsigned char **, unsigned char **);
int dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int);
int dn_skipname(const unsigned char *, const unsigned char *);
#ifdef __cplusplus
}
#endif
#endif
in the Linux headers
Linux是generally/colloquially所有具有Linux内核的unix-ish操作系统的名称,但具体来说,Linux指的是Linux 内核本身。解析 headers 不是 Linux 内核的一部分。 linux-headers
安装 headers 需要编译 Linux 个内核模块。没关系。
提到的解析器 headers 是在 glibc GNU C 库中实现的。 Alpine 发行版使用 C 标准库的 musl 实现,而不是 glibc。
how can I resolve this issue?
其中之一:
- 您可以实现
res_ninit
和依赖于 musl 的相关功能,并在编译应用程序时使用该实现
- 补丁 mysql-connector 你自己可以用 musl
编译
- compile/install glibc 到您的系统并针对它编译 mysql-connector
- 不要将 alpine 用于需要 glibc 的程序,仅使用 glibc-compatibile Linux 发行版
- 将此问题通知 mysql-connector 开发人员并在经济上支持他们,以便他们解决问题
我正在尝试从 alpine 中的源代码安装一个应用程序,它说没有 res_ninit
、res_nsearch
和 res_nclose
,但我们可以 see here Linux header 中确实存在并且我已经安装了 apk add linux-headers
,我该如何解决这个问题?
make install
Consolidate compiler generated dependencies of target save_linker_opts
[ 2%] Built target save_linker_opts
[ 2%] Built target build_protobuf
Consolidate compiler generated dependencies of target cdk_foundation
[ 3%] Building CXX object cdk/foundation/CMakeFiles/cdk_foundation.dir/socket_detail.cc.o
/dep/mysql-connector-cpp/cdk/foundation/socket_detail.cc: In function 'std::forward_list<cdk::foundation::connection::detail::Srv_host_detail> cdk::foundation::connection::detail::srv_list(const string&)':
/dep/mysql-connector-cpp/cdk/foundation/socket_detail.cc:1097:3: error: 'res_ninit' was not declared in this scope; did you mean 'res_init'?
1097 | res_ninit(&state);
| ^~~~~~~~~
| res_init
/dep/mysql-connector-cpp/cdk/foundation/socket_detail.cc:1107:13: error: 'res_nsearch' was not declared in this scope; did you mean 'res_search'?
1107 | int res = res_nsearch(&state, hostname.c_str(), ns_c_in, ns_t_srv, query_buffer, sizeof (query_buffer) );
| ^~~~~~~~~~~
| res_search
/dep/mysql-connector-cpp/cdk/foundation/socket_detail.cc:1143:3: error: 'res_nclose' was not declared in this scope
1143 | res_nclose(&state);
| ^~~~~~~~~~
make[2]: *** [cdk/foundation/CMakeFiles/cdk_foundation.dir/build.make:146: cdk/foundation/CMakeFiles/cdk_foundation.dir/socket_detail.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1061: cdk/foundation/CMakeFiles/cdk_foundation.dir/all] Error 2
更新: 我 cat header 文件 /usr/include/resolv.h
我们可以看到该函数不存在,所以问题是我该如何设置Linux header 喜欢ubuntu 可以在高山工作吗?
#ifndef _RESOLV_H
#define _RESOLV_H
#include <stdint.h>
#include <arpa/nameser.h>
#include <netinet/in.h>
#ifdef __cplusplus
extern "C" {
#endif
#define MAXNS 3
#define MAXDFLSRCH 3
#define MAXDNSRCH 6
#define LOCALDOMAINPARTS 2
#define RES_TIMEOUT 5
#define MAXRESOLVSORT 10
#define RES_MAXNDOTS 15
#define RES_MAXRETRANS 30
#define RES_MAXRETRY 5
#define RES_DFLRETRY 2
#define RES_MAXTIME 65535
/* unused; purely for broken apps */
typedef struct __res_state {
int retrans;
int retry;
unsigned long options;
int nscount;
struct sockaddr_in nsaddr_list[MAXNS];
# define nsaddr nsaddr_list[0]
unsigned short id;
char *dnsrch[MAXDNSRCH+1];
char defdname[256];
unsigned long pfcode;
unsigned ndots:4;
unsigned nsort:4;
unsigned ipv6_unavail:1;
unsigned unused:23;
struct {
struct in_addr addr;
uint32_t mask;
} sort_list[MAXRESOLVSORT];
void *qhook;
void *rhook;
int res_h_errno;
int _vcsock;
unsigned _flags;
union {
char pad[52];
struct {
uint16_t nscount;
uint16_t nsmap[MAXNS];
int nssocks[MAXNS];
uint16_t nscount6;
uint16_t nsinit;
struct sockaddr_in6 *nsaddrs[MAXNS];
unsigned int _initstamp[2];
} _ext;
} _u;
} *res_state;
#define __RES 19960801
#ifndef _PATH_RESCONF
#define _PATH_RESCONF "/etc/resolv.conf"
#endif
struct res_sym {
int number;
char *name;
char *humanname;
};
#define RES_F_VC 0x00000001
#define RES_F_CONN 0x00000002
#define RES_F_EDNS0ERR 0x00000004
#define RES_EXHAUSTIVE 0x00000001
#define RES_INIT 0x00000001
#define RES_DEBUG 0x00000002
#define RES_AAONLY 0x00000004
#define RES_USEVC 0x00000008
#define RES_PRIMARY 0x00000010
#define RES_IGNTC 0x00000020
#define RES_RECURSE 0x00000040
#define RES_DEFNAMES 0x00000080
#define RES_STAYOPEN 0x00000100
#define RES_DNSRCH 0x00000200
#define RES_INSECURE1 0x00000400
#define RES_INSECURE2 0x00000800
#define RES_NOALIASES 0x00001000
#define RES_USE_INET6 0x00002000
#define RES_ROTATE 0x00004000
#define RES_NOCHECKNAME 0x00008000
#define RES_KEEPTSIG 0x00010000
#define RES_BLAST 0x00020000
#define RES_USEBSTRING 0x00040000
#define RES_NOIP6DOTINT 0x00080000
#define RES_USE_EDNS0 0x00100000
#define RES_SNGLKUP 0x00200000
#define RES_SNGLKUPREOP 0x00400000
#define RES_USE_DNSSEC 0x00800000
#define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT)
#define RES_PRF_STATS 0x00000001
#define RES_PRF_UPDATE 0x00000002
#define RES_PRF_CLASS 0x00000004
#define RES_PRF_CMD 0x00000008
#define RES_PRF_QUES 0x00000010
#define RES_PRF_ANS 0x00000020
#define RES_PRF_AUTH 0x00000040
#define RES_PRF_ADD 0x00000080
#define RES_PRF_HEAD1 0x00000100
#define RES_PRF_HEAD2 0x00000200
#define RES_PRF_TTLID 0x00000400
#define RES_PRF_HEADX 0x00000800
#define RES_PRF_QUERY 0x00001000
#define RES_PRF_REPLY 0x00002000
#define RES_PRF_INIT 0x00004000
struct __res_state *__res_state(void);
#define _res (*__res_state())
int res_init(void);
int res_query(const char *, int, int, unsigned char *, int);
int res_querydomain(const char *, const char *, int, int, unsigned char *, int);
int res_search(const char *, int, int, unsigned char *, int);
int res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int);
int res_send(const unsigned char *, int, unsigned char *, int);
int dn_comp(const char *, unsigned char *, int, unsigned char **, unsigned char **);
int dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int);
int dn_skipname(const unsigned char *, const unsigned char *);
#ifdef __cplusplus
}
#endif
#endif
in the Linux headers
Linux是generally/colloquially所有具有Linux内核的unix-ish操作系统的名称,但具体来说,Linux指的是Linux 内核本身。解析 headers 不是 Linux 内核的一部分。 linux-headers
安装 headers 需要编译 Linux 个内核模块。没关系。
提到的解析器 headers 是在 glibc GNU C 库中实现的。 Alpine 发行版使用 C 标准库的 musl 实现,而不是 glibc。
how can I resolve this issue?
其中之一:
- 您可以实现
res_ninit
和依赖于 musl 的相关功能,并在编译应用程序时使用该实现 - 补丁 mysql-connector 你自己可以用 musl 编译
- compile/install glibc 到您的系统并针对它编译 mysql-connector
- 不要将 alpine 用于需要 glibc 的程序,仅使用 glibc-compatibile Linux 发行版
- 将此问题通知 mysql-connector 开发人员并在经济上支持他们,以便他们解决问题