Setup problem
The linker should not be trying to link your text file; best guess would be that you triggered the build command while the cursor was inside of the input.txt
file.
Make sure the input focus is in your source file before you run the build command and see if that has any effect.
Short answer: I think you need to add -mconsole
as a flag to mingw32.
Long answer: The microsoft linker (link.exe) can link executables in two ways. One way is to link it into a console application, and another way is to link it into a GUI application. When linked into a console application, the main
function is assumed to exist. When linked into a GUI application, the WinMain
function is instead used as entrypoint for the program. To select the console variant, you must pass /SUBSYSTEM:CONSOLE
to link.exe, and to select the GUI variant, you must pass /SUBSYSTEM:WINDOWS
to link.exe. I think that last flag may be the default if omitted. By searching a bit on stackoverflow I learned that apparently the equivalent flag for mingw32 is -mconsole
.
Try to first compile your main.cpp in the terminal. If you can succesfully compile it in the terminal, then write a build system to automate that task. build systems reference, and another reference, and even a YouTube video on build systems.
To get it to compile in the terminal you will likely need to invoke something like mingw32.exe path\to\main.cpp -mconsole
You should watch this video. It seems like you don’t completely understand what the g++ and gcc command line programs actually do.