g++ gives me an error while trying to compile a minimal file containing a absolute path include when the code file is refered with a path containing '/'. It fails with the following error:
>g++ ../src/main_b.cpp -o main.exe ../src/main_b.cpp:5:10: fatal error: D:/training/TestInclude.h: No such file or directory 5 | #include "D:/training/TestInclude.h" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
But it doesn't fails when calling the following:
>g++ ..\src\main_b.cpp -o main.exe
The failure only occur when the include is present in the cpp file.
CPP File:
#include <stdio.h>
#include "D:/training/TestInclude.h"
using namespace std;
int main(int argc, char const *argv[])
{
printf("B - Test\n");
return 0;
}
header file:
#ifndef __TEST_INCLUDE_H__
#define __TEST_INCLUDE_H__
#ifndef TEST_DEF
#define TEST_DEF "YOLO"
#endif
#endif
G++ version (Provided by Cygwin):
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/11/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-11.3.0/configure --srcdir=/mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-11.3.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --with-gcc-major-version-only --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lto,objc,obj-c++,jit --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.0 (GCC)
I'm trying to understand why my compilation fails, to know if it's a compiler error or an unhandled way of refering to a file for the compiler, and to know why the error is so blurry about the issue when just changing the separator resolves the issue. I made a minimal example to show it better.