Peter Rasmussen Peter Rasmussen - 10 months ago 55
C++ Question

Compiling C++ (.cpp) into an .exe file

:) Help greatly appreciated.

I am looking to convert a .cpp file to .exe.

I've tried with (MingW) gcc and g++. I also tried to manually compile it in Visual Studio.

Unfortunately these fail to compile (both on Linux and Windows) because the precompiled headers cannot be located:

stdafx.h: No such file or directory

I've tried to manually download them (the precompiled headers: #include) and change
#include <stdafx.h>
#include "stdafx.h"
to point at the current folder of the manually downloaded preheaders. This 'works' but it compiles with a massive amount of errors, probably because it's a wrong version of the header (Only place I could find the header was on

There must be a simpler way?


You can either remove the

#include "stdafx.h"

in your cpp files or use the built in template called Win32 Console Application

enter image description here