Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error: ‘NI_MAXSERV’ undeclared #495

Merged
merged 2 commits into from
Aug 27, 2022

Conversation

widgetii
Copy link
Contributor

When I compile libre using arm-linux-musleabi-gcc cross-compiler with musl library I encountered a compilation issue:

[ 59%] Building C object CMakeFiles/re-objs.dir/src/tcp/tcp.c.o
.../git/re/src/tcp/tcp.c: In function ‘tcp_sock_bind’:
.../git/re/src/tcp/tcp.c:725:12: error: ‘NI_MAXSERV’ undeclared (first use in this function)
  char serv[NI_MAXSERV] = "0";
            ^~~~~~~~~~
.../git/re/src/tcp/tcp.c:725:12: note: each undeclared identifier is reported only once for each function it appears in
.../git/re/src/tcp/tcp.c:725:7: warning: unused variable ‘serv’ [-Wunused-variable]
  char serv[NI_MAXSERV] = "0";
       ^~~~
.../re/src/tcp/tcp.c: In function ‘tcp_conn_alloc’:
.../re/src/tcp/tcp.c:886:12: error: ‘NI_MAXSERV’ undeclared (first use in this function)
  char serv[NI_MAXSERV] = "0";
            ^~~~~~~~~~
.../re/src/tcp/tcp.c:886:7: warning: unused variable ‘serv’ [-Wunused-variable]
  char serv[NI_MAXSERV] = "0";
       ^~~~
.../re/src/tcp/tcp.c: In function ‘tcp_conn_bind’:
.../re/src/tcp/tcp.c:963:12: error: ‘NI_MAXSERV’ undeclared (first use in this function)
  char serv[NI_MAXSERV] = "0";
            ^~~~~~~~~~
.../re/src/tcp/tcp.c:963:7: warning: unused variable ‘serv’ [-Wunused-variable]
  char serv[NI_MAXSERV] = "0";
       ^~~~
.../re/src/tcp/tcp.c: In function ‘tcp_conn_connect’:
.../re/src/tcp/tcp.c:1037:12: error: ‘NI_MAXSERV’ undeclared (first use in this function)
  char serv[NI_MAXSERV];
            ^~~~~~~~~~
.../re/src/tcp/tcp.c:1037:7: warning: unused variable ‘serv’ [-Wunused-variable]
  char serv[NI_MAXSERV];
       ^~~~

It turns out the same issue had OpenSSL project, and it was fixed by this commit. It resolved my issue as well.

@sreimers
Copy link
Member

It looks netdb.h related, can you try:

diff --git a/src/tcp/tcp.c b/src/tcp/tcp.c
index 15de2eec..23dc10d7 100644
--- a/src/tcp/tcp.c
+++ b/src/tcp/tcp.c
@@ -14,6 +14,7 @@
 #define __USE_POSIX 1  /**< Use POSIX flag */
 #define __USE_XOPEN2K 1/**< Use POSIX.1:2001 code */
 #define __USE_MISC 1
+#define _GNU_SOURCE 1
 #include <netdb.h>
 #endif
 #ifdef __APPLE__

@widgetii
Copy link
Contributor Author

This work as well, changed

@sreimers sreimers merged commit 6ba0821 into baresip:main Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants