1

I am running a fresh install of Linux Mint 20.1 and I'n trying to compile a program for a GPS tracker, but it won't compile:

In file included from /usr/include/c++/9/bits/stl_algo.h:59,
                 from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:142,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/QtCore:4,
                 from pch.h:27:
/usr/include/c++/9/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
   75 | #include_next <stdlib.h>
      |               ^~~~~~~~~~
compilation terminated.

I have installed a number of additional libraries (libusb, libmarble and a few others) and qmake.

Of course, stdlib.h is present on the system:

$ find /usr -name stdlib.h
/usr/include/x86_64-linux-gnu/bits/stdlib.h
/usr/include/bsd/stdlib.h
/usr/include/stdlib.h
/usr/include/c++/9/tr1/stdlib.h
/usr/include/c++/9/stdlib.h
/usr/include/tcl8.6/tcl-private/compat/stdlib.h

After looking at the other questions about this, I re-installed build-essential, which didn't help.

I re-installed the g++ compiler, no luck either.

I copied /usr/include/c++/9/stdlib.h to /usr/local/include, but it still complains about a missing stdlib.h

I changed the

#include_next <stdlib.h>

in cstdlib into

#include <stdlib.h>

only to find that the next include cannot find stdlib.h; changing that one produced the third include and so on. So that does not work either.

The program compiles and works on Slackware 14.2 by the way.

What am I missing?

Hello-world compiles normally; a simple program that does a malloc also compiles and runs.

Ljm Dullaart
  • 4,273
  • 2
  • 14
  • 31
  • I had some problems too a few months ago in a Linux Mint version upgrade https://stackoverflow.com/q/63537391/6865932, some libraries were exhibiting strange behaviors, not only that but some devices were not working properly, I could only solve it by reinstalling the system, hopefuly you won't need to do that. – anastaciu Apr 06 '21 at 11:35
  • 1
    Diagnostic step: is the toolchain hosed or just the specific build misconfigured? Try making a hello world including something from stdlib.h (let's say malloc), compile by hand. –  Apr 06 '21 at 11:38
  • both work; added it to the question. – Ljm Dullaart Apr 06 '21 at 14:09
  • https://forum.qt.io/topic/87751/qtcreator-compile-returning-stdlib-h-no-such-file-or-directory/7 <- this looks somewhat relevant - do you have INCLUDEPATH somewhere? –  Apr 06 '21 at 14:24
  • There were some directories added to the INCLUDEPATH in the Makefile. I tried to compile by hand (`gcc -c xxxx -Idirectory` etc.) but I still got the missing includes. – Ljm Dullaart Apr 08 '21 at 06:53

1 Answers1

0

I used to @anastaciu 's solution.

As it was a fresh install without much customization, I resorted to the option of a complete re-install. Bizarre that that works a bit, as it was already a fresh install. I still had to copy stdlib.h and a few others (math.h etc.) to /usr/local/lib` to get to the point where it would at least compile.

Ljm Dullaart
  • 4,273
  • 2
  • 14
  • 31