Tutorial: Building Handmade Hero w/ VS 2015

After seeing quite a few questions about compiler errors, I thought I'd try to help make it easy as possible to get a running build going. So here's a quick tutorial video to that effect. Hope it helps.

Building Handmade Hero From Pre-o... Files (As of Day 261 w/ VS 2015)

Also, the below seemed worth writing down somewhere (e.g. for those starting from day one and wondering what the other files are for):

You first need "Handmade Hero (Test Assets)" on Day 36.

You first need "Handmade Hero Art Pack 0 (intro_art.hha)" on Day 221.

Edited by theinternetftw on Reason: more info, vs version note
Now I can see the font rendering.

Great stuff, Thanks!! :)
You should put "with VS2015" in title or at least in description.

Edited by Mārtiņš Možeiko on
You should put "with VS2015" in title or at least in description.

Duly noted and added.

Edit: actually mmozeiko (or anybody else, if they get there first), could you try something for me if you're running VS2013?

put -Wv:18 -wd4244 in the compiler flags and see if everything still works. If it does, I'll be able to make a new video with one set of instructions that will work for either compiler version.

Edited by theinternetftw on Reason: idea!
For VS2013 you don't need any extra flags. Casey is using VS2013 and it compiles without any warning as you can see on stream.

And /Wv is new compiler flag introduced in VS2015. VS2013 doesn't support it. Here it's shown in docs:
https://msdn.microsoft.com/en-us/library/thxezb7y(v=vs.120).aspx (not present)
https://msdn.microsoft.com/en-us/library/thxezb7y(v=vs.140).aspx (present)

Edited by Mārtiņš Možeiko on
For VS2013 you don't need any extra flags. Casey is using VS2013 and it compiles without any warning as you can see on stream.

I'm aware of that.


/Wv is new compiler flag introduced in VS2015

Crap. Just thought it would be nice to have a single path that supported both compilers.

Edited by theinternetftw on
Maybe do som kinda #ifdef in build.bat if that's possible? I'd guess some people upgrade to VS2015 someday...
Yes, you can do it in bat file with if statement.
VS2013 sets "VisualStudioVersion" variable to "12.0", but VS2015 sets its value to "14.0".
Or you can check presence of VS120COMNTOOLS variable. VS2013 will have it, but VS2015 won't (it will have VS140COMNTOOLS variable).

Edited by Mārtiņš Možeiko on
You can definitely do something like that, I was just hoping it'd be a simple single-line add thing.

Here's what that would look like

Shell.bat's environment setup call would look like:

1
2
3
4
5
6
7
if exist "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" (
  set VC_SCRIPT="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
) else (
  set VC_SCRIPT="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
)

call %VC_SCRIPT% x64


and right at the beginning of build.bat, you might have something like this:

1
2
3
4
5
@echo off

if exist "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" set VS2015_OPTS=-Wv:18 -wd4244 

set CommonCompilerFlags=-Od -MTd -nologo -fp:fast -fp:except- -Gm- -GR- -EHa- -Zo -Oi %VS2015_OPTS% -WX -W4 -wd4201 -wd4100 -wd4189 -wd4505 -wd4127 -FC -Z7


(edit: oops, martins had already answered you (of course :D) while I was falling down the batch script rat hole)

Edited by theinternetftw on
Except that the second line after else should have 12 instead of 14 :-)
Edited that in just as you posted that
1
:)

Edited by theinternetftw on Reason: fighting valiantly against the emoticon image replacement system
:-)
Yeah, it's better to check for variable that vsvarsall sets.
Otherwise if I have both VS2013 and VS2015 studios installed and will modify shell.bat to use environment for the one I want (VS2013), then build.bat will work incorrectly - it will always prefer VS2015 if you have both of them, and nothing will work correctly.

And I don't feel that preferring VS2015 over VS2013 is a good choice. If somebody has both VS installed there is no reason to use VS2015 for building HH. Because Casey is using VS2013 then also using VS2013 will lead to less problems.

Edited by Mārtiņš Možeiko on
Yeah, it's better to check for variable that vsvarsall sets. Otherwise if I have both VS2013 and VS2015 studios installed and will modify shell.bat to use environment for the one I want (VS2013), then build.bat will work incorrectly

Good point.


VS2013 will lead to less problems.

The main reason I lean toward adopting VS 2015 (which, admittedly, is completely undone by -Wv:18), is at least having the ability to get variable shadowing warnings, which, for me at least, are much appreciated. I've already been bitten several times by copy/pasting a variable declaration into an inner scope by accident, just in following handmade hero alone.

Edited by theinternetftw on