How come when I try to compile my C program by making a file named for the program it creates an application for it?

It is normal for the compiler to generate an application!

What is surprising is the location for the executable, it should have been generated in the parent directory:

 C:\TDM-GCC-64\> gcc Chess/chess.c Chess/init.c -o chess

The explanation is interesting:

  • You are using the Windows operating system, where the filenames are case insensitive.
  • You instructed gcc to generate the executable into chess, but this is the name of the Chess directory. In this case, gcc generates the executable in the named directory and gives it a name that is the basename of the first source file chess.c -> chess.
  • Furthermore, the application name really is chess.exe in Windows, but the default setting for the file manager is to not display file extensions. This is a very unfortunate choice. I suggest you change this setting in the Windows/File Explorer Options window to always show file extensions. This will allow you to distinguish chess.c, chess.exe and chess.h more easily.

You have a Makefile in the Chess directory, you should use the make command to build the executable:

 C:\TDM-GCC-64\> make -C Chess

Or simply cd to the Chess subdirectory and type:

 C:\TDM-GCC-64\Chess> make

Browse More Popular Posts

Leave a Comment