#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Gcc.exe: fatal error: no input files


    Hello! I am trying to set up my computer to work on C programming required for my class in school.

    I have used this guide from youtube: I can't post url

    Basic summary:
    • Download latest mingw from mingw.org, then install mingw with gcc/c/c++ packages.
    • CMD then "cd .." twice to go to only c drive. Then do "cd /mingw" and "cd bin" to get to that directory. Then type "g++ --version" and "gcc --version" and both of them were installed.
    • Then I type "mingw-get install mingw32-make" and everything installed ok.
    • Then I went into system, advanced system settings, environment variables and set up PATH and Path for both User and System (C:\MinGW\bin).
    • Then I shut down my PC and turn it on again and went into cmd and typed "gcc" and "g++" and it said "fatal error no input files" for both and the guy in video says this is good and that it should say that.
    • Then I download TEXTPAD from Textpad.org (saved to program files x86, just like the guy in the video).
    • Then I configure -> preferences to set up tools. I set up Compile C (add program, go to bin directory and pick gcc.exe, named it Compile C, then I put parameter "-o $BaseName$File" and regular expression "^\(\(\(.[^:]\)\|\([A-Za-z]:\)\)[^:]+\):\*([0-9]+\):". I also changed line from 2 to 4
    • then i set up Run C (add DOS command, typed in "cmd.exe" then renamed it Run C, then named parameter $BaseName and unchecked "capture output")


    Everything worked as described above, no problems or errors.

    Now I try to make my file. I click save as and save it as test.C
    Windows says it's C file, not txt.
    I write my program.

    #include <stdio.h>

    int main(void)
    {
    printf("Hello");
    return 0;
    }

    Then I try run Compile C and it says "gcc.exe: fatal error: no input files".

    I searched google and this forums and I simply don't find anything. I tried saving my file in multiple locations and it's always the same.
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,174
    Rep Power
    2222
    Stupid question: what does your invocation look like? IOW, exactly how did you try to compile?

    Were you in the directory where you had saved test.c?

    At the command line, did you type this command or something very much like it?:
    gcc -Wall test.c

    At the very least when you invoke gcc, you need to give it the name of the source file. I very strongly suggest that you use the -Wall option, which displays warnings; warnings are much more important than error messages, should always be displayed, and should never ever be ignored.

    If that's not it, then a really odd thought just occurred to me. MinGW gcc is a Windows port of the Linux GNU C compiler, gcc. In Windows/DOS the case of the letters in a file name are not important; Windows/DOS is case-insensitive. However, UNIX/Linux is case-sensitive, so the file extensions .c and .C are different and mean different things. In UNIX, .c means it's a C source file whereas .C makes it C++. What just occurred to me and what I don't know is whether they had ported that interpretation of the .C file extension over to MinGW gcc. I doubt that they would have done that, plus the error message doesn't really point to it. Just an odd thought.
    Last edited by dwise1_aol; October 10th, 2013 at 09:30 AM.
  4. #3
  5. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,174
    Rep Power
    2222
    Looking at it again, the problem appears to be in the TextPad set-up. That would be verified by you CD'ing to the directory where the source file has been saved and running gcc from the command line as I described.

    Originally Posted by gdiuezhfieu
    • Then I configure -> preferences to set up tools. I set up Compile C (add program, go to bin directory and pick gcc.exe, named it Compile C, then I put parameter "-o $BaseName$File" and regular expression "^\(\(\(.[^:]\)\|\([A-Za-z]:\)\)[^:]+\):\*([0-9]+\):". I also changed line from 2 to 4
    • then i set up Run C (add DOS command, typed in "cmd.exe" then renamed it Run C, then named parameter $BaseName and unchecked "capture output")
    I am not familiar with that aspect of TextPad nor with having set up anything similar in another editor -- I always just run gcc from the command line as it was meant to be run.

    All I see you setting up there is the -o option which names the resultant executable; without the -o option, the executable's name defaults to a.exe (a.out on Linux). How are you setting up the source file's name in that command? I am assuming that you assume that TextPad plugs that in automatically, but the error message seems to differ from your assumption. You also need to add in the -Wall option to display all warnings; that is very important.

    I recommend that you search for information on inserting the current filename into a command. If TextPad has a forum, you should find somebody else there who had the same problem.

    BTW, more benefits to compiling and building from the command line:
    1. You don't need to resort to kludges in your program in order to keep it from terminating and closing the console window before you have a chance to read it.

    2. You can build a project with multiple source files by including all those file names in your invocation. This can be simplified by placing all the source files in one directory (and have no other source files in that directory) and typing in the command:
    gcc -Wall *.c

    3. You can add in libraries that you need to link in. For example, if you do sockets programming, you would need to link in ws2_32.a with the -lws2_32 option. Or since my installation doesn't automatically link in the math library, if I use a function in math.h then I need to also add the option -lm. With your set-up, it looks like you'd have to change it every time you had to do something slightly different, which would break it for all your other projects so you'd have to change it back.

    Just saying.

    PS
    Looking at the Compile Java example, the Parameters textbox says $File. I would assume that that is a place marker for the name of the source file. See what happens when you add that back in to the Compile C parameters.
    Last edited by dwise1_aol; October 10th, 2013 at 10:53 AM.
  6. #4
  7. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,113
    Rep Power
    1803
    Not your problem now, but possibly your next problem, but you should be aware that GCC will perform C++ compilation on a file with a .C (capital) extension. You should use .c (lowercase) for C code.

    Ref: http://gcc.gnu.org/onlinedocs/gcc-4....name-suffix-71
  8. #5
  9. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,113
    Rep Power
    1803
    Originally Posted by gdiuezhfieu
    Windows says it's C file, not txt.
    I would not trust Windows' file name extension recognition - configure Explorer options to always show file name extensions including known file types. Not that that is your problem here either.
  10. #6
  11. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,113
    Rep Power
    1803
    Originally Posted by gdiuezhfieu
    [*]Then I download TEXTPAD from Textpad.org (saved to program files x86, just like the guy in the video).[/list]
    Do yourself a favour and get a more complete IDE such as Code::Blocks. The Windows' distribution includes MinGW, and the IDE provides an easy to use interface to the GNU debugger (gdb) which you will find invaluable.

    Knowing how to build from the command line is sometimes useful, but not useful enough that you need to learn that first, and not essential to success in programming at all.

IMN logo majestic logo threadwatch logo seochat tools logo