Monday, 3 June 2019

It's been a while - C++ and the case of the missing headers

Whilst trying to compile some code on my Linux box which, of course, is an IBM mainframe running Ubuntu, I was seeing this: -

/usr/include/features.h:424:12: fatal error: sys/cdefs.h: No such file or directory
 #  include
compilation terminated.

I'd started with a clean-but-minimised Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-36-generic s390x) environment, and had installed vim: -

sudo apt-get install vim

to create a test CPP source file: -

vi test.cpp

int main()
        return 1;

but, when I attempted to compile it: -

g++ --verbose -o test test.cpp 

I saw the previously quoted exception.

I checked that I had libc installed: -

sudo apt-get install libc6-dev
sudo apt-get install libc6

I did check the missing file: -

sudo find / -name cdefs.h

which returned: -


ls -al /usr/include/sys/cdefs.h

lrwxrwxrwx 1 root root 30 Apr 16  2018 /usr/include/sys/cdefs.h -> ../s390x-linux-gnu/sys/cdefs.h

which gave me a clue ...

After some digging around, I found this: -

on AskUbuntu, which referenced the apt-file command: -

sudo apt-get install apt-file
sudo apt-file update

Having installed it, I ran it: -

apt-file find cdefs.h|grep s390

which showed: -

libc6-dev: /usr/include/s390x-linux-gnu/sys/cdefs.h
libc6-dev-s390: /usr/include/sys/cdefs.h
libc6-dev-s390x-cross: /usr/s390x-linux-gnu/include/sys/cdefs.h

Taking a leap o' faith, I installed the s390 element of libc6-dev: -

sudo apt-get install libc6-dev-s390

but to no avail.

I then did the same for the s390x-linux-gnu element: -

sudo apt-get install libc6-dev-s390x-cross

which did the job.

I'm now able to compile my test module and, more importantly, I'm able to build the Docker image that led me down this particular rabbit hole ( as it uses LuaJIT )

No comments:

Docker and Node and macOS - Computer Said No

I'm using a Docker container that runs a NodeJS application to lint-check YAML files relating to my new best friend,  Tekton CD . This c...