I'm trying to do a cross-compile with MinGW g++ and it seems to have selective issues finding files in a system include folder.
It finds stdio.h
fine, and finds libio.h
fine, but it fails to find _G_config.h
even though all three files are in the same folder, with the same permissions, being included in the same way.
Here's the verbose output (unwrapped to make legible; username scrubbed):
-\Documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\arm-linux-gnueabihf-g++.exe -v -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"MainSPI.d" -MT"MainSPI.o" -o "MainSPI.o" "../MainSPI.cpp"
Using built-in specs.
COLLECT_GCC=C:\Users\user-------------\Documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\arm-linux-gnueabihf-g++.exe
Target: arm-linux-gnueabihf
Configured with: /home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/snapshots/gcc-linaro-5.3-2016.02/configure
SHELL=/bin/bash --with-bugurl=https://bugs.linaro.org --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/i686-w64-mingw32 --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/i686-w64-mingw32 --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/i686-w64-mingw32 --with-gnu-as --with-gnu-ld --disable-libstdcxx-pch --disable-libmudflap --with-cloog=no --with-ppl=no --with-isl=no --disable-nls --enable-c99 --with-tune=cortex-a9 --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-multilib --enable-multiarch --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/sysroots/arm-linux-gnueabihf --enable-lto --enable-linker-build-id --enable-long-long --enable-shared --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/i686-w64-mingw32/arm-linux-gnueabihf/libc --enable-languages=c,c++,fortran,lto --enable-checking=release --disable-bootstrap --with-bugurl=https://bugs.linaro.org --build=x86_64-unknown-linux-gnu --host=i686-w64-mingw32 --target=arm-linux-gnueabihf --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/i686-w64-mingw32
Thread model: posix
gcc version 5.3.1 20160113 (Linaro GCC 5.3-2016.02)
COLLECT_GCC_OPTIONS='-v' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-MMD' '-MP' '-MF' 'MainSPI.d' '-MT' 'MainSPI.o' '-o' 'MainSPI.o' '-shared-libgcc' '-march=armv7-a' '-mtune=cortex-a9' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu'
c:/users/user-------------/documents/case-sensitive/gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/5.3.1/cc1plus.exe -quiet -v -imultilib . -imultiarch arm-linux-gnueabihf -iprefix c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../lib/gcc/arm-linux-gnueabihf/5.3.1/ -isysroot c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../arm-linux-gnueabihf/libc -MMD MainSPI.d -MF MainSPI.d -MP -MT MainSPI.o -dD -D_GNU_SOURCE ../MainSPI.cpp -quiet -dumpbase MainSPI.cpp -march=armv7-a -mtune=cortex-a9 -mfloat-abi=hard -mfpu=vfpv3-d16 -mthumb -mtls-dialect=gnu -auxbase-strip MainSPI.o -g3 -O0 -Wall -version -fmessage-length=0 -o
C:\Users\user\AppData\Local\Temp\cce7dljB.s
GNU C++ (Linaro GCC 5.3-2016.02) version 5.3.1 20160113 (arm-linux-gnueabihf)
compiled by GNU C version 4.9.1, GMP version 6.0.0, MPFR version 3.1.3,
MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "c:/users/user-------------/documents/case-sensitive/gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf/lib/gcc/../../lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../arm-linux-gnueabihf/include/c++/5.3.1"
ignoring duplicate directory "c:/users/user-------------/documents/case-sensitive/gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf/lib/gcc/../../lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../arm-linux-gnueabihf/include/c++/5.3.1/arm-linux-gnueabihf/."
ignoring duplicate directory "c:/users/user-------------/documents/case-sensitive/gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf/lib/gcc/../../lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../arm-linux-gnueabihf/include/c++/5.3.1/backward"
ignoring duplicate directory "c:/users/user-------------/documents/case-sensitive/gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf/lib/gcc/../../lib/gcc/arm-linux-gnueabihf/5.3.1/include"
ignoring nonexistent directory "c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../arm-linux-gnueabihf/libc/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/i686-w64-mingw32/lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../include/arm-linux-gnueabihf"
ignoring nonexistent directory "c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../arm-linux-gnueabihf/libc/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/i686-w64-mingw32/lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../include"
ignoring duplicate directory "c:/users/user-------------/documents/case-sensitive/gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf/lib/gcc/../../lib/gcc/arm-linux-gnueabihf/5.3.1/include-fixed"
ignoring duplicate directory "c:/users/user-------------/documents/case-sensitive/gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf/lib/gcc/../../lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../arm-linux-gnueabihf/include"
#include "..." search starts here:
#include <...> search starts here:
c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../arm-linux-gnueabihf/include/c++/5.3.1
c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../arm-linux-gnueabihf/include/c++/5.3.1/arm-linux-gnueabihf/.
c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../arm-linux-gnueabihf/include/c++/5.3.1/backward
c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../lib/gcc/arm-linux-gnueabihf/5.3.1/include
c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../lib/gcc/arm-linux-gnueabihf/5.3.1/include-fixed
c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../arm-linux-gnueabihf/include
c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../arm-linux-gnueabihf/libc/usr/include/arm-linux-gnueabihf
c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin\../arm-linux-gnueabihf/libc/usr/include
End of search list.
GNU C++ (Linaro GCC 5.3-2016.02) version 5.3.1 20160113 (arm-linux-gnueabihf)
compiled by GNU C version 4.9.1, GMP version 6.0.0, MPFR version 3.1.3,
MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: d41011bf5dc0e7b64084b0a5dc2942fd
In file included from c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\arm-linux-gnueabihf\libc\usr\include\stdio.h:75:0,
from ../MainSPI.cpp:4:
c:\users\user-------------\documents\case-sensitive\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\arm-linux-gnueabihf\libc\usr\include\libio.h:32:23:
fatal error: _G_config.h: No such file or directory
compilation terminated.
And here's my double checking that yes the files are in the 8th/last search directory:
...abihf/arm-linux-gnueabihf/libc/usr/include$ ls -l _G_config.h stdio.h libio.h
-rwxrwxrwx 1 root root 2526 Jun 19 2017 _G_config.h
-rwxrwxrwx 1 root root 17790 Jun 19 2017 libio.h
-rwxrwxrwx 1 root root 31525 Jun 19 2017 stdio.h
...abihf/arm-linux-gnueabihf/libc/usr/include$ sed -n '32p' libio.h
#include <_G_config.h>
...abihf/arm-linux-gnueabihf/libc/usr/include$ sed -n '75p' stdio.h
#include <libio.h>
I don't think it's relevant but this is on Windows 10 with WSL enabled and I enabled the case sensitive filesystem for the folder case-sensitive
.
As for my actual question: Why can't g++ find _G_config.h
and how can I fix it so it can?
I am not sure whether this is THE answer. But, I faced a similar situation with Linaro GCC 5.5.0-2017.10 and it turned out to be an issue with the path length on Windows. This could be the case for you too, as the file that is not being found has a longer name than the two that are found (as it was in my case). The test is simple, remove some levels from your directory structure (for the purpose of this test) [e.g. by just moving the base folder or your project, or renaming parts of it with a shorter name], and see if the build starts working.