-1

First of all, I made a simple program to test if compiling was working properly, it is as follows:

#include <iostream>

int main() {
    std::cout << "Oi!";
}

Quite simple indeed, should compile properly, right? Wrong.
I am using MinGW for Windows 10, just to let you know.

I tried compiling it using "cpp <file name>.cpp -o a.exe" and was, first time, going through with the compile, but once I tried to execute the file it would send me this:

./a.exe: line 14: namespace: command not found
./a.exe: line 20: syntax error near unexpected token `('
./a.exe: line 20: `  typedef decltype(nullptr) nullptr_t;'

Clearly something was wrong, so I searched for a solution, found out someone had a similar problem and doing a reinstall solved it, so I went to the MinGW installation manager, noticed the C++ compiler library wasn't installed and installed it. It felt I was doing alright.

I also noticed that they were using g++ instead of cpp and tried that instead, it worked properly this time, but I would like to note that I have "git bash" installed, so I assume it used "git bash" 's command and not MinGW's.

So I opened cmd and tried using cpp, once I tried executing the program cmd said that the software wasn't compatible with the version of windows being executed, that doesn't sound right. I did a verbose compile with cpp and noticed this oddity:

#include <...> search starts here:
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++/mingw32
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++/backward
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include-fixed
End of search list.

That doesn't follow Windows's file path standard...
Does it have anything to do with the problems I am facing? I just want things to compile! ;w;

Thermite
  • 1
  • 2
  • 2
    cpp is the C pre-processor, not a C++ compiler. The system C++ compiler is usually `c++` (as the system C compiler is `cc`). – Stephen Newell Mar 04 '21 at 21:15
  • I'm not sure what is the tool `cpp` that you are using. Can you share the link to the compiler's website? Also, when you say it worked with `g++` and you _assumed_ it used the one from `git bash`, you can actually verify where the command is used from by using `where g++`. – Zoso Mar 04 '21 at 21:15
  • You should be using `g++` with that said 6.3 is pretty old the current version is 10.2 and that is available using msys2. Related: [https://stackoverflow.com/questions/30069830/how-to-install-mingw-w64-and-msys2](https://stackoverflow.com/questions/30069830/how-to-install-mingw-w64-and-msys2) – drescherjm Mar 04 '21 at 21:56
  • "note that I have "git bash" installed, ...so ... used "git bash" 's command" ---- bash ( I think all of them ) search for the command in the same way. On my Linux, I use the command 'env' to show the environment variables and their values. In there, you should find "SHELL" which will inform you of the shell you are using, and "PATH" which presents a list of dir's and the search order. On my system, "which g++" reports "/usr/bin/g++", and "ls -lsa /usr/bin/g++" reports "g++-9". You should try diff shells, and confirm they report what command g++ invokes (i.e. "g++-9" on my Linux) – 2785528 Mar 04 '21 at 22:32

1 Answers1

0

As mentioned above, you need to use g++ to compile your code. Try the command g++ --version If you get any result that doesn't include a version number you need to install g++. Here is a guide that may be helpful. https://techsupportwhale.com/install-gcc-compiler-on-windows/