Right now I am reading Peter Shirley's Ray Tracing in One Weekend book, I want to be able to use the provided source code but I am not sure what platform or IDE it was written on, because of this it does not compile in Visual Studio.

Can somebody help me? Whenever I try compiling the code it asks me to 'attach to process'.

How can I get this working? In a few reviews I have read online it says that I'll need to do some tweaking to get it working but I honestly don't know how. Would it mean rewriting the entire ray tracer as a Win32 Project?


1 Answer 1


No MakeFile or Visual Studio Solution file is provided. So you will need to do the setup yourself in the Visual Studio IDE. Note that you could just drag and drop the files (.h and .cc are known extensions to Visual Studio) in a new console application if you are not/less familiar with Visual Studio.

The code itself is just plain C++ code. No special stuff. So it does not matter which platform or IDE was used during development. In fact the code is pretty self containing except for

#include <math.h>
#include <stdlib.h>
#include <iostream>
#include "float.h" -> <float.h>

But if your Visual Studio is installed and configured correctly, every console application can just include these headers without any problems. (Just try a basic hello world console application, since the problem has in my opinion nothing to do with the code you want to use.) Note that you need a Win32 Console application and NOT a Win32 Project.

It could be possible that the pre-compiled header file is enabled (StdAfx.h or pch.h) in which case you could disable this or include the header as the first included header in every .cpp file.

  • $\begingroup$ Thanks! So your saying I need to create a Win32 Console Application -> Import all Files and I should be good to go? $\endgroup$ Feb 26, 2017 at 12:12
  • $\begingroup$ Try this first: msdn.microsoft.com/en-us/library/jj620919.aspx Then drag and drop your files and your main function instead. (And remember what I said about Precompiled Headers) $\endgroup$
    – Matthias
    Feb 26, 2017 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.