My OS is Windows 10. I'm using command prompt this time to compile.
according to the book that I am reading, to compile all the source files and make it an object files, (in the current directory) do it by typing this command:
gcc -c *.c
it says the operating system will replace *.c with all the C filenames
But why am I getting this error?
gcc: error: *.c: Invalid argument
gcc: fatal error: no input files
compilation terminated.
I'm in the right directory. And when I compile my source files with their respective names, it's working properly. But the '*.c' is not working.
And the same error in linking the object files using '*.o'
Is that command not for windows OS? If not, what is for windows?
Newbie here.
On Unix systems and environments (like MSYS or Cygwin) , wildcards are expanded by the shell (depends), but in Windows CMD, wildcards are expanded and interpreted by the program that receives. This sounds strange, but cmd.exe
does not support wildcard expansion (as an interpreter), but some of its built-in commands do, like COPY
.
Use a simple program to verify it.
#include <stdio.h>
int main(int argc, char *argv[]){
int i;
for (i = 1; i < argc; i ++)
printf("%s\n", argv[i]);
return 0;
}
Sample output on Unix:
$ ./a.out /*
/bin
/boot
/dev
...
/usr
/var
$ ./a.out /\*
/*
$
Sample output on Windows:
C:\Windows\system32>a.exe C:\*
C:\*
C:\Windows\system32>
If you want to let something else expand the wildcard for your program, use MinGW (MSYS) or Windows Subsystem for Linux (Win 10 1607 and later).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With