philippedax/vreng

Build issue with Ubuntu

Closed this issue · 6 comments

make  all-recursive
make[1]: Entering directory '/home/mugi/vreng-9.4.4'
Making all in src
make[2]: Entering directory '/home/mugi/vreng-9.4.4/src'
Making all in base
make[3]: Entering directory '/home/mugi/vreng-9.4.4/src/base'
depbase=`echo nsl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
clang++-18 -DHAVE_CONFIG_H -I. -I../..  -I../../src -I/usr/include/libxml2     -I../../src/ai -I../../src/base -I../../src/ubit -I../../src/gui -I../../src/world -I../../src/net -I../../src/2d -I../../src/model -I../../src/3d -I../../src/vnc -I../../src/tool   -g  -Wall -D_REENTRANT -MT nsl.o -MD -MP -MF $depbase.Tpo -c -o nsl.o nsl.cpp &&\
mv -f $depbase.Tpo $depbase.Po
nsl.cpp:41:43: error: expected '(' after 'static_cast'
   41 |   if ((hp =  static_cast<struct hostent *>)malloc(sizeof(struct hostent)))) != NULL)
      |                                           ^
      |                                           (
nsl.cpp:41:75: error: extraneous ')' after condition, expected a statement
   41 |   if ((hp =  static_cast<struct hostent *>)malloc(sizeof(struct hostent)))) != NULL)
      |                                                                           ^
nsl.cpp:41:77: error: expected expression
   41 |   if ((hp =  static_cast<struct hostent *>)malloc(sizeof(struct hostent)))) != NULL)
      |                                                                             ^
nsl.cpp:63:11: error: no matching function for call to 'gethostbyname_r'
   63 |   hptmp = gethostbyname_r(hostname, &result, buf, sizeof(buf), &err);
      |           ^~~~~~~~~~~~~~~
/usr/include/netdb.h:177:12: note: candidate function not viable: requires 6 arguments, but 5 were provided
  177 | extern int gethostbyname_r (const char *__restrict __name,
      |            ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  178 |                             struct hostent *__restrict __result_buf,
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  179 |                             char *__restrict __buf, size_t __buflen,
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  180 |                             struct hostent **__restrict __result,
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  181 |                             int *__restrict __h_errnop);
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 errors generated.
make[3]: *** [Makefile:452: nsl.o] Error 1
make[3]: Leaving directory '/home/mugi/vreng-9.4.4/src/base'
make[2]: *** [Makefile:360: all-recursive] Error 1
make[2]: Leaving directory '/home/mugi/vreng-9.4.4/src'
make[1]: *** [Makefile:417: all-recursive] Error 1
make[1]: Leaving directory '/home/mugi/vreng-9.4.4'
make: *** [Makefile:358: all] Error 2

I tried building on Ubuntu 22.04.4 WSL with Clang 18.
Same error on real debian 12.5.0 with GCC.

It doesn't seem to take into account that gethostbyname_r is different for each environment.

Many thanks for your feedback.

I thinks it's now fixed (commit ff62b13).

Philippe

Thank you.
I tried to build it again, but an error occurred if I didn't explicitly cast the argument of gethostbyname_r to int.

When I fixed that, the error still occurred because the library was not included.

Apparently, libraries were not detected correctly in configure.ac, so the library detection method also needs to be corrected.

Please, which argument ? There are 6 arguments for gethostbyname_r.
Can you send me a trace of compilation ?

The library to be include should be -l nsl

please grep GET.*BYNAME config.h and send me the result.

Thanks

Oops the library to be included should be libc standard (-lc).

I maintain vreng on a Mac under MacOS-10.13 and I have not gethostbyname_r.

nsl.cpp: In function ‘hostent* my_gethostbyname_r(const char*, int)’:
nsl.cpp:67:26: error: invalid conversion from ‘int’ to ‘hostent*’ [-fpermissive]
   67 |   hptmp = gethostbyname_r(hostname, &result, buf, sizeof(buf), &hptmp, &err);
      |           ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                          |
      |                          int
make[3]: *** [Makefile:454: nsl.o] Error 1
make[3]: Leaving directory '/home/mugi/vreng/src/base'
make[2]: *** [Makefile:362: all-recursive] Error 1
make[2]: Leaving directory '/home/mugi/vreng/src'
make[1]: *** [Makefile:419: all-recursive] Error 1
make[1]: Leaving directory '/home/mugi/vreng'
make: *** [Makefile:360: all] Error 2

It seems like the #if block isn't working. After deleting that block, it works, but libraries such as freetype2 are not recognized, so it stops due to that.

I think I have fixed, but I can't test

struct hostent ret;
struct hostent result;
int r;
int err;
char buf[512];

r = gethostbyname_r(hostname, &ret, buf, sizeof(buf), &result, &err);
if (r == 0)
return result;
else
return NULL;