So I recently ran into a problem trying to build a program using under chromeos (chronos).
I cloned the repository and as instructed ran ./autogen.sh
. No problems this far.
However, when I ran ./configure
I got the following message:
checking arpa/inet.h usability... no
This told me that the configure script wasn't able to find the arpa/inet.h
header file, however it didn't tell me where it was looking for.
Given that a regular chrome installation is pretty unusual, I wasn't surprised with getting some kind of error, but the message wasn't helpful at all as to how to fix it.
So my questions where:
./configure
looking for the headers?For the first question I looked into the configure
file itself. It was a shell script so I could just replace append -x
to #! /bin/sh
at the very top to make shell echo every command it ran.
That turned out to be unmaneagable since configure
was huge and there was a lot of jumping between functions. So I wondered what was that magical configure
script and what was that ./autogen.sh
script that I ran earlier and how could I make it run in a more verbose manner. Turns out that autogen is a description that's read by autoconf and the result is written as a configure
file. Turn's out there's a documentation page explaining how to debug the resulting script.
As instructed I have wrapped the call that checked for arpa/inet.h
in the configure
script with set -x
and set +x
.
I couldn't find any find
or anything similar in it but I saw some gcc -E test.c
here and there. I guessed that autoconf
was creating a simple C
file that contained an #include
directive and then autoconf
parsed the output of gcc
to tell if the header could be found at all.
So my next test was to create a simple test file that did exactly that:
#include <arpa/inet.h>
I saved the above content as a C
file and tried compiling it with gcc -E test.c > /dev/null
. The output was this:
In file included from /usr/local/include/sys/socket.h:33,
from /usr/local/include/netinet/in.h:23,
from /usr/local/include/arpa/inet.h:22,
from test.c:1:
/usr/local/include/bits/socket.h:390:10: fatal error: asm/socket.h: No such file or directory
390 | #include <asm/socket.h>
| ^~~~~~~~~~~~~~
compilation terminated.
That told me that one of the dependencies of arpa/inet.h
was importing asm/socket.h
and failing to find it.
After reaching this far I wanted to make sure that gcc
was looking in the right places for the headers before proceeding any further. Fortunately there's a page in the documentation that explains that.
Running,
cpp -v /dev/null -o /dev/null
I obtained the follwing in the output:
...
#include <...> search starts here:
/usr/local/include
/usr/include
End of search list.
...
/usr/local/include
was indeed where my header files were. And answering the second question, no I didn't have asm/socket.h
somewhere else. Googling I found that it was supposed to be included in the linux source header files, normally found in a distribution package.
As I was using chromebrew I needed to run crew install linuxheaders
to get them.
And that was how I answered the third question. By installing the packages configure
was able to run and generate the make files and I was able to build and install openfortivpn
.
Hopefully this will be useful to someone (probably myself) in the future.