[gnutls-devel] undefined reference to htons and ntohs (Android)

Nikos Mavrogiannopoulos nmav at gnutls.org
Fri Nov 7 19:05:45 CET 2014

On Fri, 2014-11-07 at 13:50 +0100, A. Klitzing wrote:
> Hi,
> I compiled gnutls 3.3.9 for Android with Googles NDK (standalone
> toolchain) and get some linker errors. The library will be built but
> some cmdline tools don't....
> I can successfully build gnutls 3.3.6.
> Any hints for me? It would be enough if I can disable the build of any
> cmdline tool.
> [...]
> Making all in src
> Making all in gl
> Making all in libopts
>   CCLD     gnutls-cli-debug
>   CCLD     certtool
>   CCLD     ocsptool
>   CCLD     danetool
>   CCLD     gnutls-serv
> socket.o:socket.c:function port_to_service: error: undefined reference
> to 'htons'
> socket.o:socket.c:function service_to_port: error: undefined reference
> to 'ntohs'

Maybe these are macros. Would the issue go away if you add #include
<arpa/inet.h> in socket.c?


More information about the Gnutls-devel mailing list