Q: I created a simple source file
hello.c, but when I invoke
the compiler, it says: "gcc.exe: hello.c: No such file or directory",
and then exits with the message "No input files." But
is there, so why won't the compiler find it??
A: One popular reason for this problem is that you use one of those
Windows editors that think they know better how do you want them to name
the files. For example,
Notepad always attaches the
.txt extension to the file name you provide, so when you type
hello.c into the dialog box,
Notepad actually creates
hello.c.txt. In addition, the files listed by
Computer by default have their extensions not shown, which creates an
hello.c really is there.
DIR command in the DOS Box to see what files are in
the directory where you run GCC. (If you have the GNU Fileutils
installed, you can use
ls as well.) This will always show the
full names of the files, exactly like GCC sees them.
You are generally advised to stay away of such "helpful" editors.
Notepad is not suited well for editing programs, anyway. If
you must use it, a work-around is to type the file name in quotes:
Notepad will leave it alone and not
Another reason for GCC to not be able to find the source file is because you use long file names on Windows/NT. Suppose you invoke GCC like this:
gcc -c file_name.c
file_name.c exceeds the DOS 8+3 limits, so if you have
such a file, you probably created it with some Windows editor. However,
DJGPP programs cannot access long file names on Windows/NT, so gcc
doesn't find such a file and complains.
Type dir /x from the command line to see the short 8+3 alias name
of your file (in the example above, it should be
some such), and use that short name when you invoke GCC. In general, if
you want to avoid such problems on Windows/NT, you should restrict
yourself to file names that are valid DOS 8+3 names.
|webmaster donations bookstore||delorie software privacy|
|Copyright © 2001 by Eli Zaretskii||Updated Apr 2001|