Error 1: no input files when making a c file

2019-09-20 13:58发布

问题:

I'm trying to compile a c-file with dependencies, using a makefile that gets stuck with this error:

Compiling tpc_lqe.o ...
/cygdrive/c/Sandbox/ZigBee/Tools/ba-elf-ba2/bin/ba-elf-gcc -c -o tpc_lqe.o  
[some -options]
-I/cygdrive/c/Sandbox/ZigBee/Components/TPC/Include 
-I/cygdrive/c/Sandbox/ZigBee/Components/TPC/Source 
-I/cygdrive/c/Sandbox/ZigBee/Components/AppApi/Include 
-I/cygdrive/c/Sandbox/ZigBee/Components/Common/Include 
-I /cygdrive/c/Sandbox/ZigBee/Components/TPC/Source/tpc_lqe.c -MD -MF tpc_lqe.d -MP
ba-elf-gcc: no input files
make: *** [tpc_lqe.o] Error 1
Makefile:138: recipe for target 'tpc_lqe.o' failed

I saw other questions regarding the same error, but I can't relate to them with my problem.

This is the makefile line that is causing the error, please point out if some context is missing:

%.o: %.c
    $(info Compiling $@ ...)
    $(CC) -c -o $*.o $(CFLAGS) $(INCFLAGS) $< -MD -MF $*.d -MP

Update following unwind's answer:

I didn't include specify a variable (include path of a library), which caused the following inclusion of that variable (INCFLAGS) to contain a blank space in its stead. This blank space ended up in the -I option thus returning the error.

Once defined that variable, everything worked smoothly.

回答1:

INCFLAGS looks broken, since the compiler invocation has a "bare" -I, without a value immediately following, which causes gcc to interpret the next argument (the source file name) as that argument:

[...] -I /cygdrive/c/Sandbox/ZigBee/Components/TPC/Source/tpc_lqe.c
        ^
        |
       ???