6

I just freshly installed Qt Creator 4.1.0 Based on Qt 5.7.0 (GCC 4.9.1 20140922 (Red Hat 4.9.1-10), 64 bit)

This error drives me crazy after I fixed all kit errors, actually I spent some time on google looking for proper compiler. This could be something with compiler version I think:

/usr/include/c++/5.3.1/cstddef:45: error: stddef.h: No such file or directory

I saw solutions for windows everywhere but could not find for linux, does anyone has experience how to fix it?

Screenshots

Compilers

Qt versions

Kits

rpm -qa | grep devel | sort

expat-devel-2.1.0-10.fc22.x86_64
fontconfig-devel-2.11.94-4.fc22.x86_64
freetype-devel-2.5.5-2.fc22.x86_64
gdbm-devel-1.11-4.fc22.x86_64
glibc-devel-2.21-13.fc22.i686
glibc-devel-2.21-13.fc22.x86_64
java-1.8.0-openjdk-devel-1.8.0.65-3.b17.fc22.x86_64
kernel-debug-devel-4.2.5-201.fc22.x86_64
kernel-debug-devel-4.2.6-200.fc22.x86_64
kernel-devel-4.2.6-200.fc22.x86_64
libdb-devel-5.3.28-12.fc22.x86_64
libdrm-devel-2.4.61-3.fc22.x86_64
libICE-devel-1.0.9-2.fc22.x86_64
libpng-devel-1.6.16-3.fc22.x86_64
libSM-devel-1.2.2-2.fc22.x86_64
libstdc++-devel-5.3.1-6.fc22.i686
libstdc++-devel-5.3.1-6.fc22.x86_64
libXau-devel-1.0.8-4.fc22.x86_64
libxcb-devel-1.11-8.fc22.x86_64
libXcursor-devel-1.1.14-4.fc22.x86_64
libXdamage-devel-1.1.4-6.fc22.x86_64
libXext-devel-1.3.3-2.fc22.x86_64
libXfixes-devel-5.0.1-4.fc22.x86_64
libXft-devel-2.3.2-2.fc22.x86_64
libXi-devel-1.7.4-2.fc22.x86_64
libXinerama-devel-1.1.3-4.fc22.x86_64
libXrandr-devel-1.4.2-2.fc22.x86_64
libXrender-devel-0.9.9-1.fc22.x86_64
libxshmfence-devel-1.2-1.fc22.x86_64
libXt-devel-1.1.4-10.fc22.x86_64
libXv-devel-1.0.10-2.fc22.x86_64
libXxf86vm-devel-1.1.4-1.fc22.x86_64
libX11-devel-1.6.3-1.fc22.x86_64
mesa-libGL-devel-10.6.9-1.20151008.fc22.x86_64
mesa-libGLU-devel-9.0.0-7.fc22.x86_64
perl-devel-5.20.3-328.fc22.x86_64
python3-devel-3.4.2-6.fc22.x86_64
qt-devel-4.8.7-4.fc22.x86_64
systemtap-devel-2.9-1.fc22.x86_64
systemtap-sdt-devel-2.9-1.fc22.x86_64
xorg-x11-proto-devel-7.7-12.fc21.noarch
zlib-devel-1.2.8-7.fc22.x86_64
tstenner
  • 10,080
  • 10
  • 57
  • 92
Dušan Tichý
  • 498
  • 1
  • 7
  • 21

3 Answers3

14

I had this problem as well, and for me I had to disable ClangCodeModel plugin. To do this, I went to Help->About Plugins...->Uncheck ClangCodeModel (under C++ category). After restarting QT Creator, everything was working fine. I found this solution on QT Forums

null
  • 407
  • 5
  • 13
4

If the compiler works from a terminal, it should work from QtCreator. So first make it work from the terminal.

From a terminal, create a file main.cpp with:

#include <cstddef>
int main()
{
    return 0;
}

Then type the command:

gcc -H main.cpp -o main
  • If the compilation works, there must be a problem in your kit definition in QtCreator. Possibly make sure the folder where stddef.h is in the include file list of your kit. But you should not need to do that. Temporarily, you can add the include path to your project (see How to add include path in Qt Creator?) to check this is really the problem. Then you'll need to find a way to fix the kit for good.

  • If the compilation does not work, fix your environment (possibly using sashoalm's commented link). QtCreator is just and IDE, if you run it with a broken compiler it won't fix it for you. The compilation output will show where files (cstddef and then stddef.h) are picked from (-H option). Try cpp -v to see where included files are searched.

On my machine, compilation output gives me:

. /usr/include/c++/4.8/cstddef .. /usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h ... /usr/include/x86_64-linux-gnu/c++/4.8/bits/os_defines.h .... /usr/include/features.h ..... /usr/include/x86_64-linux-gnu/sys/cdefs.h ...... /usr/include/x86_64-linux-gnu/bits/wordsize.h ..... /usr/include/x86_64-linux-gnu/gnu/stubs.h ...... /usr/include/x86_64-linux-gnu/gnu/stubs-64.h ... /usr/include/x86_64-linux-gnu/c++/4.8/bits/cpu_defines.h .. /usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h Multiple include guards may be useful for: /usr/include/c++/4.8/cstddef /usr/include/x86_64-linux-gnu/bits/wordsize.h /usr/include/x86_64-linux-gnu/gnu/stubs-64.h /usr/include/x86_64-linux-gnu/gnu/stubs.h /usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h

see stddef.h was found in /usr/lib/gcc/x86_64-linux-gnu/4.8/include

And cpp -v gives:

#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.

Note: If you created the kit manually, I would recommend that you uninstall QtCreator. Make gcc work from a terminal and then reinstall QtCreator. This one should create the kits automatically and they should then work.

Community
  • 1
  • 1
jpo38
  • 20,821
  • 10
  • 70
  • 151
0

This is a common problem with QT I experience a lot with all versions of Fedora, the problem is that the path to "/usr/lib64/qt5/bin" is missing from the user environment.

To check for the path at a command line what the path is present set to enter the following: echo $PATH

You should see the "/usr/lib64/qt5/bin" listed somewhere in the response if it is not present then edit the .bashrc file in the root of your home directory as follows: -

Add QT5 build environment

if! [[ "$PATH" =~ "/usr/lib64/qt5/bin" ]]
then
  PATH="/usr/lib64/qt5/bin:$PATH"
fi

Just above the "export PATH" statement

You will need to log off and on again for the changes to take effect.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241