Archive for March, 2008

New Blog Location, Please Update your links, RSS

Saturday, March 29th, 2008

This blog is back at http://www.stackpointer.org/blog so please update your links, RSS aggregators, or whatever hullabaloo you use to read my blog.

Comments Are Enabled

Tuesday, March 18th, 2008

By the by, I disabled having to register to comment.

The Codebook

Thursday, March 13th, 2008

I’ve been keeping a journal that I call “The Codebook” for the past four of five years. When people see it for the first time, they usually ask me something like: “So.. are you with the NSA then..?”, and I although cliche, reply with something like: “I can neither confirm nor deny my involvement with the NSA”. Anyway, The Codebook is a notebook that I write down all of my programming ideas, work through technical problems, and keep track of what I’m working on.

The content of The Codebook is intractable. It ranges from C++-pseudo code, and algorithm analysis, to mocked up maps that I plotted out when I did that Legend of Zelda clone I wrote back in college. It’s also organized very poorly. Anybody who looked at it would probably think it’s gibberish Computer Science, or some kind of nerd stream of consciousness piece. For instance, I just found an outline of what my plans for JuiceMUD were, right next to a rather large listing of UNIX programs, and then on the next page there’s some mysterious binary work surrounded by blank paper.

This all leads me to a question: how do you keep your technical thoughts organized?

Codebook Cover Codebook Example Codebook Map

Compiling libpng in Visual Studio .NET {2005}

Saturday, March 1st, 2008

There is very spotty documentation on how to use libpng under Windows. I did find one site that talks about the subject, so you might want to refer to it as well.

1. Libpng Setup:

First, you’ll need to download the latest version of libpng and zlib. Extract them someplace (I placed them within my projects root, in a directory called ‘deps’). The pre-canned Visual Studio settings that come with libpng look for ‘zlib’ rather than ‘zlib-x.y.z’, so rename the directories so that they lack the version numbers.

2. Compiling libpng and zlib

Next go into <projectname>\deps\libpng\projects\visualc71 and open libpng.sln. Go to Build and run ‘Clean Solution’. Now you have a choice, you can either compile libpng as a dynamically loaded library, or a binary blob to statically link into your executable. You can compile either one as a debug or release build. Just make sure that whichever way you compile libpng (debug/release), is the same as what you compile your project. So choose an option, and go to Build -> Build Solution. This will compile both libpng and zlib.

3. Project Setup

Now you’ll need to set your project up to include the libpng and zlib files. Open your Visual Studio project, and go to Project -> <projectname> Properties. Expand Configuration Properties, and then expand C/C++. The top field on the right will read “Additional Include Directories”. Click it and add “C:\<projectname>\deps\zlib;C:\<projectname>\deps\libpng”.

Now close the C/C++ tree and expand the Linker tree, which is directly below it. Roughly 3/4 of the way down is a field called “Additional Library Directories”. Click it and add

“C:\<projectname>\deps\libpng\projects\visualc71\<projecttype>\ZLib;
C:\AnimTester\deps\libpng\projects\visualc71\<projecttype>”.

In my case, I compiled as Win32_LIB_Debug (Statically Linked, Debug Symbols included), so that’s what I set <projecttypeyoucompiledas> to.

Next open the Input node that is in the Linker tree. Under “Additional Dependancies” add libpngd.lib zlibd.lib if you chose to statically link, or libpng13d.lib zlib1d.lib if you compiled it as a dll. If you did compile as a dll, you will then need to copy the dll’s that were generated to the same directory as your executable, or to a directory loaded in PATH.

Now you can implement PNG reading or writing into your project.

4. Troubleshooting

Q: I get a ton of linking errors!
A: Visual Studio cannot find the lib files. Double check that they are compiled (libpng{..}.lib, zlib{…}.lib), that your projects Library dependancies includes the directories that they are in, and that the lib files are included in the Additional Dependancies field.

Q: Visual Studio spits out errors about undeclared identifiers!
A: Make sure you have #include <png.h> in your source. Also make sure that png.h’s path is included under Additional Included Directories in your projects settings.