Peter Rasmussen Peter Rasmussen - 1 year ago 139
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download