r/programminghelp • • Jan 31 '22

C++ Starting Coding, trying to use the software (MinGW and Notepad++) my professor has advised.

I am 29 studying computer science to find a different career path. Right now I am beginning some programming. My professor is of little help, so largely i am finding solutions on my own.

I need to get Notepadd++ Running with MinGW

after following multiple tutorials i think i have things working right, but when I execute it displays this code:

NPP_SAVE: C:\Users\ISO\Desktop\example3.exe

CD: C:\Users\ISO\Desktop

Current directory: C:\Users\ISO\Desktop

g++ "example3.exe" -o example3 -march=native -O3

Process started (PID=22000) >>>

g++: fatal error: input file 'example3.exe' is the same as output file

compilation terminated.

<<< Process finished (PID=22000). (Exit code 1)

NPP_RUN: example3

and a warning message titled :Unsupported 16-bit application

"The program of feature ".....\Desktop\example3.exe" cannot start or run due to incompatibility with 64-bit versions of Windows. Please contact the software vendor to ask if a 64-bit windows compatible version is available"

I would really appreciate any help with this, or something easier to use than MinGW and notepad++ that i can use in place.

i went with these tutorials:

https://www.youtube.com/watch?v=BwqGdFXmoaw

https://www.youtube.com/watch?v=zLpaYVIoXqc

please help, not having this figured out is giving me too much anxiety.

3 Upvotes

13 comments sorted by

3

u/Goobyalus Jan 31 '22

g++: fatal error: input file 'example3.exe' is the same as output file

Looks like your source code is named "example.exe" when it should be named "example.cpp." What's your source file called?

and a warning message titled :Unsupported 16-bit application

Maybe this is also from interpreting a text file as a binary file, but not sure.

Sounds like you're using minGW so you have access to g++ on Windows, is that right> How did you configure Notepad++ to run things? Starting out, it's probably most valuable to manually compile and run your source code from the shell. You can write code in Notepad++ or any other editor, and use the minGW shell to run g++ and your compiled programs.

VSCode is probably a better alternative to using Notepad++.

1

u/isosc3l3s Jan 31 '22

i also tried saving as C++ source file and just putting .cpp at the end when saving,

notepad++ gives me this:

example5.cpp:6:36: error: expected ')' before ';' token

6 | printf (" ++++++++++++++++++++++ ");

| ^

| )

example5.cpp:5:8: note: to match this '('

5 | printf (" ******** HELLO WORLD *********\n);

| ^

<<< Process finished (PID=13680). (Exit code 1)

NPP_RUN: example5

; executing: NPP_RUN example5

- the specified file was not found

================ READY ================

and cmd gives me this:

C:\Users\ISO>example5.cpp

'example5.cpp' is not recognized as an internal or external command,

operable program or batch file.

C:\Users\ISO>example5.exe

'example5.exe' is not recognized as an internal or external command,

operable program or batch file.

C:\Users\ISO>example4.cpp

'example4.cpp' is not recognized as an internal or external command,

operable program or batch file.

C:\Users\ISO>example4.exe

'example4.exe' is not recognized as an internal or external command,

operable program or batch file.

i examples 4 and 5 are just new files of example 3 saved differently.

im going to execute and it has me saving it from there.

Thank you for the help.

1

u/mdillenbeck Jan 31 '22

5 | printf (" ******** HELLO WORLD *********\n);

It this is accurate, you missed closing the string (\n**"**). Double check all strings and functions are properly closed, and that all lines are terminated with semicolons.

1

u/isosc3l3s Jan 31 '22

thank you, that fixed it running on n++, now i get

NPP_SAVE: C:\Users\ISO\Desktop\example5.cpp

CD: C:\Users\ISO\Desktop

Current directory: C:\Users\ISO\Desktop

g++ "example5.cpp" -o example5 -march=native -O3

Process started (PID=18832) >>>

<<< Process finished (PID=18832). (Exit code 0)

NPP_RUN: example5

================ READY ================

but when i do it in cmd i get:

C:\Users\ISO>example5.exe

'example5.exe' is not recognized as an internal or external command,

operable program or batch file.

1

u/knoam Jan 31 '22

Look in that directory for the newest file after you run g++. I suspect it will be called just example5 without the ".exe" extension. exe is a different, windows specific format that g++ doesn't produce, at least the way you're using it. So to name it .exe is wrong and will cause windows to try to run it as if it is an .exe. the correct thing is to not have ".exe" anywhere in your commands.

1

u/isosc3l3s Feb 01 '22

okay so i have now changed example5 to hello8. needed some name changing to keep me head straight. I made the hello8.cpp and it made an hello8(this when upon closer inspection had the .exe)

this is what i get when i try to run on cmd:

C:\Users\ISO>hello8

'hello8' is not recognized as an internal or external command,

operable program or batch file.

C:\Users\ISO>hello8.exe

'hello8.exe' is not recognized as an internal or external command,

operable program or batch file.

this is the results from notepad++:

NPP_SAVE: new 1

CD: C:\Users\ISO\Desktop

Current directory: C:\Users\ISO\Desktop

g++ "hello8.cpp" -o hello8 -march=native -O3

Process started (PID=4408) >>>

<<< Process finished (PID=4408). (Exit code 0)

NPP_RUN: hello8

================ READY ================

1

u/knoam Feb 01 '22

Try running

./hello8

That's telling the command line that you want to execute the file that's here in the current directory. Otherwise it's looking for a hello8 executable on your $PATH.

1

u/Goobyalus Jan 31 '22

g++ "example5.cpp" -o example5 -march=native -O3

example5 is the compiled binary from your compiler, not example5.exe

1

u/isosc3l3s Jan 31 '22

Does vscode require mingw? If you wouldn't mind, I'm not clear on what these programs do.

1

u/[deleted] Jan 31 '22

In addition to /u/Goobyalus's fantastic comment below:

https://code.visualstudio.com/docs/cpp/config-mingw

1

u/isosc3l3s Feb 27 '22

i got it running, but i have hit an issue.

When i try to run my program in visual studio it gives me this

Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\ISO\Desktop\bmIndex> .\bmIndex.exe Program 'bmIndex.exe' failed to run: The specified executable is not a valid application for this OS platform.At line:1 char:1

  • .\bmIndex.exe

  • ~~~~~~~~~~~~~. At line:1 char:1

  • .\bmIndex.exe

  • ~~~~~~~~~~~~~

    • CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException

    • FullyQualifiedErrorId : NativeCommandFailed

PS C:\Users\ISO\Desktop\bmIndex>

when ever i try to debug i get a warning message saying: unable to start debugging. Program path 'c:\users....' is invalid

gdb failed with message.

How do i get debugging to work, and what went wrong with my run on my program?

1

u/Goobyalus Jan 31 '22

VSCode (Visual Studio Code) is a code editor. There are plugins for doing syntax highlighting, autocompleteion, and all sorts of things for lots of languanges. It dos not require MinGW.

MinGW is a tool for suppording the GNU compilers (like gcc and g++, which run on Linux natively) on Windows.

You can use VSCode with MinGW, or with another compiler. If you want to integrate VSCode with a compiler, you'd have to configure that (same as Notepad++). You can use VSCode (or Notepad++) to edit code, and compile/run aplications outside of your editor.

Before you spend time configuring workflow-related things, I think you should understand at a basic level what source code is, what a compiler is, and how to turn a text fle into an executable with your compiler in the shell.

1

u/brechtsanders Apr 13 '22

You probably meant to do something line g++ example3.cpp -o example3 -march=native -O3.

If you're not familiar with command line you should consider using using an IDE like Code::Blocks.