I am trying to install an application from its source code in the alpine it says there is no res_ninit
, res_nsearch
and res_nclose
but we can see here that do exists in the Linux headers and I have already installed apk add linux-headers
, how can I resolve this issue?
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
Update: I cat the header file /usr/include/resolv.h
and we can see that function does not exists, so the question is how can I set up Linux header like ubuntu that can work in the alpine?
#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
CodePudding user response:
in the Linux headers
Linux is generally/colloquially the name of all unix-ish operating systems with a Linux kernel, but specifically, Linux refers to the Linux kernel tiself. The resolve headers are not part of Linux kernel. linux-headers
install headers needed to compile Linux kernel modules. It's unrelated.
The mentioned resolver headers are implemented inside glibc GNU C library. Alpine distribution uses musl implementation of C standard library, not glibc.
how can I resolve this issue?
One of:
- you can implement
res_ninit
and relevant function that depend on musl and use that implementation when compiling the application - patch mysql-connector yourself to be compilable with musl
- compile/install glibc to your system and compile mysql-connector against it
- do not use alpine for programs that require glibc and use only glibc-compatibile Linux distribution
- notify mysql-connector developers about the issue and financially support them so they will fix the issue