Peter Rasmussen Peter Rasmussen - 2 months ago 8
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>
to
#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 https://sourceforge.net)

There must be a simpler way?

Answer

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

Comments