I recently upgraded my Docker based automatic build system to use the latest Ubuntu:
RUN export DEBIAN_FRONTEND="noninteractive" && apt update && apt-get install -y wget g++ build-essential mingw-w64 subversion libmysqlclient-dev libgcrypt20-dev libgmp-dev libsqlite3-dev qt5-default libudev-dev python3.5 python3-lxml
RUN wget https://cmake.org/files/v3.9/cmake-3.9.3-Linux-x86_64.tar.gz
RUN tar zxf cmake-3.9.3-Linux-x86_64.tar.gz
RUN cd cmake-3.9.3-Linux-x86_64 && tar c * | tar x -C /usr
The old system worked fine with these commands. The new one didn't, the MinGW builds failing with the compiler complaining that the following line in cstdlib
failed to find "stdlib.h":
/usr/lib/gcc/i686-w64-mingw32/7.3-win32/include/c++/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>
I don't know what versions of Qt5 and MinGW I had in the old system but it would have been whatever came as standard with Xenial at the time I built it.
I upgraded cmake from the manual 3.9.3 install to the latest Ubuntu package, and it made no difference.
I found this post which was enormously helpful, but very out of date:
https://bugzilla.redhat.com/show_bug.cgi?id=1470809
My solution was to edit /usr/i686-w64-mingw32/lib/cmake/Qt5Core/Qt5CoreConfig.cmake and similar files for Qt5Gui and Qt5Widgets with the following change:
< set(_Qt5Core_OWN_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/" "${_qt5Core_install_prefix}/include/QtCore")
---
> set(_Qt5Core_OWN_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtCore")
I.e. to remove the include path "${_qt5Core_install_prefix}/include/"
.
While this works, I am loathe to accept it as a permanent fix.
My questions are:
- is this a bug in Qt or MinGW?
- How do I get a proper fix?
P.s. this is not a duplicate of mingw/include/c++/cstdlib: stdlib.h: No such file or directory which does not use CMake or Qt, and as this question should clearly indicate, the source of the error is in the CMake file included by Qt. Furthermore, the unaccepted answer to that question was to set an environmental variable. In my case I am using QtCreator which is responsible for setting up the environment for me.
UPDATE: I solved this issue by modifying the CMake files as above and this has been the state of play for so long it is effectively permanent. I do not know if this has been properly fixed by Qt yet.