C and MinGW: How do I fix my "No such file or directory" error?

I have made a python "compiler" that helps me compile my C code with gcc, for example it fetches all my header files and source files. So my cmd commmand is gcc {headers} {source} -o {build_dir}/build.exe -lgdi32 -w where {headers} is a string like -Ipath/to/headers/foo.h -Ipath/to/other/headers.foo2.h and where {source} is the same but with .c files. It seems that the compiler finds the header files, but when compiling my code it fails.

(btw I am trying to make a portable programming environment on my flash drive so python and mingw are both portable)

This is the error: fatal error: test.h: No such file or directory #include "test.h"

My project tree

I have put the third party library files into the mingw directory instead of making a custom one and then linking it in the gcc command.

1 answer

  • answered 2022-01-19 16:38 user17732522

    The -I option takes the path to the directory containing the header files or more specifically with an argument -Ipath and a directive #include<a/b.h>, the compiler will try to look for the header file at path/a/b.h.

    So you should not give it paths to header files, only to the directory or directories relative to which you use include directives.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum