Cowboy Programming

Game Development and General Hacking by the Old West

August 31st, 2007

Why won’t it build?

It’s a timeless tale; you find some useful looking code sample on the internet, you download it, you try to build it and it does not build. This is such a common occurrence that non-building code samples seem to greatly outnumber correctly building code samples on the internet by a factor of ten to one.

So I was incredibly surprised when yesterday I attempted to build the programming language Ruby from scratch on my Vista Desktop. As was expected, it did not build, but the amount of fiddling I had to do was actually incredibly small – pretty all I had to do was figure out one cryptic line in the instructions: “Execute win32\configure.bat on your build directory”, and I was nearly good to go.

Then I tried the same thing on my XP laptop, and I got an error (“cl error 0×2″, which is not incredibly helpful), and I’m stuck (well, I was programming in bed, so I was not strongly motivated to figure it out).

NMAKE : fatal error U1077: ‘cl’ : return code ’0×2′

But it got me thinking, why do hardly any code samples build? Well, in my experience it is always because something is either A) The Wrong Version or B) Missing. Problem B is generally the easier to solve, except in the rather unfortunately common case where something being missing means that another version is used, and it ends up being A – wrong.

1) Wrong or Missing Paths
Paths tell the tools where to look for things. If the paths are wrong, or missing, then the tools will look for things in the wrong place, and might find the wrong version, or they might find nothing. Unless your paths are correct, it does not matter what else it correct. The order of paths is very important, as the build tools (or Windows, if just running a tool) will look through them in that order.

2) Wrong or Missing Tools
Tools build things in a particular way. If you have the wrong tools, then things might build differently, or not at all. If a tool is missing, then hopefully the build will just stop, but sadly it might just find another (older, newer, or just wrong) version of the tool, and use that.

3) Wrong or Missing source
No every sample includes all the source you need. You might need another bunch of code, perhaps DirectX, TK, or the Windows SDK. Not everyone tells you this. The code might even require a particular version. If it does not find what it is looking for, it might use nother version. This can depend on your paths, but the source you need (usually header files), might simply be missing.

4) Wrong or Missing Library
Likewise with libraries, it might not be linking because it’s the wrong version. Symbol not found? What exactly is being linked here?

5) Wrong or Missing Environment Variables
Paths are one specific example here, but you often get things like compile and link options in environment variable, and symbols may be defined, and various other build flags. Perhaps a batch file is included that sets these? Perhaps there is a text file that describes how you should set them manually.

So of these, what is going on with my laptop build of Ruby? I’d only got as far as trying to do the “configure” step when I got the error. Now in this case I’m rather luck in that I have a working version, and an non-working version, so I can hopefully just play “what’s the difference”. Let’s check things one at a time:

1) Paths: I build from the “Visual Studio 2005 Command Prompt” that is part of Visual C++ 2005 Express edition. This sets up various paths and variables for me. Any difference here? Well, I have a different version of the DirectX SDK, but it’s after the visual studio stuff which is all the same.

2) Tools, check the version numbers, usually you can just run the tool and it will tell you, or run it with /h, –help, -v, /v or somesuch option.
Version for cl.exe – (desktop) 14.00.50727.762, (laptop) 14.00.50727.42 So that’s different. looks like I have a slightly older version of Visual Studio on my Laptop. Try to install the latest version? (Hmm, looks like Visual Studio 2008 Betas are out – must resist the urge to try it…). 200MB of downloads and two dubious restarts later and nothing has changed.

At this point I’m suspecting some configuration problem, based on scant clues from the internet, so I go straight for the environment variable, and realize I missed off the paths that are set in the environment variable, so I check those (just run SET in the command prompt you are using to build) and……

Laptop has
INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;

Desktop has:
Include=C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;C:\Program Files\Microsoft Platform SDK\Include

It looks at first like the Microsoft Platform SDK is missing, but it turns out I had it. I just need to hard wire in the missing path to INCLUDE (and another for LIB) and it worked!

(Note you’ll get the same error if you simply did not have Microsoft Platform SDK installed, make sure you have that first. )

You know, it would be very helpful if the ruby configuration batch file (win32\configure.bat) had attempted to diagnose some common problems, instead of simply letting it run until a cryptic error. And why are other errors being suppressed? There would probably have been a more useful error, like “file xxxxxx not found”.

August 29th, 2007

Speeding up slow Vista

Vista must have been designed by committee, everyone wanting to get their own pet features in there, and not caring about the effect on the overall user experience. I had some trepidation about Vista when I saw a preview video a few months before it was released, and in about 15 minutes all they were able to show was:

1) Transparent Title Bars on windows
2) Buttons that glow a bit when the mouse is over them
3) Preview windows on the task bar
4) A 3D window manager on windows-tab

That’s it? That’s what I’m expected to pay $200 for? Sheesh! Anyway, long story short, I buy it, install it, discover that is in fact just about all you get, and Vista is a lot slower user experience than XP, despite my computer having a Vista Experience Index Base Score of 5.1, with a 5.9 for graphics (the highest possible score).

So how to speed it up? Well, first I upgraded from 2GB to 4B Ram, but I can’t really say it makes much of a difference. In fact Windows can’t actually give that extra 2GB to your applications, but I thought it would at least keep it for itself, and use it for caching or something. It seems it needs a lot of the address space for trivialities, so I suspect a lot of my megabytes are sitting idle.

So what else, Google is a good place to start, here’s a useful article that suggest things you can do.

http://www.extremetech.com/article2/0,1558,2110595,00.asp
Some handy tips there, Under Control Panel->Uninstall a Program->Turn Windows features on or off, I remove:
Table PC Optional Components (Handwriting? No thank you)
Telnet client (I’d use PuTTY if I wanted telnet)
Telnet Server (why?)
Windows DFS Replication Service (Don’t use it)
Windows Fax and Scan (Fax is DEAD!)
Windows Meeting Space (Don’t use it)

This, of course makes Vista churn for ten minutes and then another ten minutes to reboot. While this is going on, I also discover from reading more of the ExtremeTech article, that I can use a USB drive as extra disk cache, using an actual feature of Vista called “ReadyBoost”. Sounds like a good idea. For some reason my “High Speed” 1GB Sony memory stick pro duo is not suitable (read speed 1943 KB/s), but my rather old 1GB Lexar thumb drive is (read 4483 KB/s, write 6913KB/s). It’s flashing away right now, but I’m unsure of what it is doing. I think I might try buying a really fast USB drive and see if it helps.

I also went into the Control Panel\System and Maintenance\Performance Information and Tools, then there a bunch of options on the left you can adjust for improvements: First the “Manage Startup Programs”, I turn off anything I don’t want running at startup. In my case this was Picasa, Steam, and a few others to do with some specific hardware devices I had, but did not really use.

Then, and this seemed to be a big one, under “Adjust Visual Effects”, I turned off EVERYTHING except for “Show thumbnails”, “Show translucent”, “show window contents” and “smooth edges of screen fonts”. This made quite a significant difference in the speed of navigating folders. This is basically turn off all the flashy features that I saw in that video. Windows now looks boring again, but runs faster, which is what I want.

Under Adjust Indexing Options, I limited it to the Start Menu, and my documents folder.

Under Adjust Power Settings, I changed it from “Balanced” to “High Performance”, which according to their little infographic, gives you TWICE THE PERFORMANCE as “Balance”. I doubt that, but I want speed! Speed! Speed! I’m bamboozled as to what it’s doing here. Why not default to the fastest setting?

Next we have “Open Disk Cleanup”, which scans my C: drive (may take a few minutes), then tells me of a whole range of files I can delete, including 8 GB of temporary files, WTF? Anyway, I select 13GB of files and delete them. Does this speed up my computer? No, not really, but I was getting a little low on disk space, so it’s all good. After it deleted that I ran it again, and clicked on the “More Options”, where it handlity told me I could free up more space by removing programs I do not use. Now this is something I don’t do much, in part because it takes so long. But now my computer is zipping along, I might delete that demo of Harry Potter, et al. I also deleted “all but the most recent restore point”, although it failed to tell me how much space this saved.

Onwards, I click on the enticing “Advanced Options”, and then “View performance details in Event Log”, this turns out to be quite the gold mine of information. Some little elf in the system does actually care about performance, and makes a note whenever the computer slows down, and even figures out why. Now I’d love for that elf to actually TELL ME, but no, it just makes a note. But the notes are sometimes telling.

-\Garmin\Training Center.exe – This process is doing excessive disk activities and is impacting the performance of Windows: (Hmm, I’ll shut that one after using it now. Normally I just let things sit there. I’d already made it not start automatically).

One from a few days ago:

The Desktop Window Manager is experiencing heavy resource contention.
Reason : Graphics subsystem resources are over-utilized.
Diagnosis : A consistent degradation in frame rate for the Desktop Window Manager was observed over a period of time.

Hopefully that’s fixed now, with me turing off all those fancy “Aero” features. I just wish they would tell me. And, hey, look, there’s an option – “Attach Task to This Event”, whcih adds a task to the Task Scheduler, triggered by this event, to pop up a window. Hmm, we’ll see hoe that goes – if the system is slowing down, it seems unlikely that popping up a window is going to help much.

Next, “Open reliability and Performance Monitor”, this is kind of like the performace tab on the task manager, (and you can get here from there), but gives a lot more detail about what is doing what. Right now I see my documents are still being indexed, and firefox is using 100MB.

Finally, “Generate System Health Report”. Supposedly will tell me how well my system is doing and recommend ways of improving it. That might have been useful YESTERDAY before I started removing everything. But anyway, does not tell me anything useful.

One final tip, for which I really should get a new UPS battery, “Enable write caching on the disk“. Makes me slightly nervous, but, okay, I’ll order a new battery (my USP has a red light telling me I should do this).

Blimey! Photoshop just started up in under ten seconds, and that’s after a reboot, so it’s not in the cache! It re-started in four seconds. View a PDF – 1 second, yay!

I’d also removed the anti-virus software, the firewall and user account settings some time ago.

Finally, my windows Vista is nearly as good as my Windows XP!

Actually, I think it’s possibly better. There are actually useful things in Vista. I like the fast indexed searching (once I set indexing to just the folder I want). I like being able to just type in the name of a program in the start menu (even just a bit of it, like “middle earth”). Now, although I’ve not used it much, it’s does actually seem, possibly, to be faster than XP.

|