2

I wrote the following on a notepad and save it as hello_world.cpp in the following folder: C:\cplusplus

#include <iostream>

main(int argc, char* argv[])
{
    std::cout << "Hello World\n";
    return 0;
}

I brought up cmd.exe and executed the following code to compile the cpp file.

C:\Program Files (x86)\CodeBlocks\MinGW\bin>g++.exe C:/cplusplus/hello_world.cpp
-o hello_world.o

However, I got the following error message:

g++.exe: error: CreateProcess: No such file or directory

I wonder if someone could point out what I did wrong.

Thank you!

jww
  • 97,681
  • 90
  • 411
  • 885
tkj80
  • 181
  • 1
  • 3
  • 10
  • 1
    Possible duplicate of [CreateProcess: No such file or directory](https://stackoverflow.com/questions/3848357/createprocess-no-such-file-or-directory) – OrdoFlammae Sep 16 '18 at 21:46
  • Possible duplicate of [Yet Another MinGW "gcc: error: CreateProcess: No such file or directory"](https://stackoverflow.com/q/13321980/608639) and [mingw32-g++.exe: error: CreateProcess: No such file or directory again](https://stackoverflow.com/q/34319405/608639) – jww Sep 17 '18 at 03:38
  • But I have to ask.... Why suffer Linux on Windows problems with Cygwin, MinGW, MSYS and friends? Use [Visual Studio Build Tools](https://stackoverflow.com/q/40504552/608639) for native Windows compilation from the command line. Or setup a Linux VM on Windows and use GCC inside Linux. (When in Rome, do as the Romans do...) – jww Sep 17 '18 at 03:42

2 Answers2

1

I think the problem is "/" which is used in Linux. In Windows is "\". Try: C:\Program Files (x86)\CodeBlocks\MinGW\bin>g++ c:\cplusplus\hello_world.cpp -o hello_world.o

Fire_Eyes
  • 11
  • 1
-1

The instructions do say to re-login after setting MingGW up. I'd reboot, just for good measure.

OrdoFlammae
  • 721
  • 4
  • 13
  • i'm new to c++. I started a new post because I was wondering if the code within hello_world.cpp could potentially be source of the problem. MinGW g++ wasn't recently installed. It came with CodeBlock that I've been using to learn C++ for a while. I tried the same compilation code on another computer - it seems to execute without any error message but I couldn't find where hello_world.o file is, – tkj80 Sep 17 '18 at 01:52
  • hello_world.o is wherever you ran the command from. Also, the only place I know of where this happens is when the variables haven't updated the way they should've, so that's why you login. I guess CodeBlocks does something weird with the compiler, I've never tried their bundled compiler. – OrdoFlammae Sep 17 '18 at 02:16