Saturday, March 03, 2007

Linux Build Fun - Part 2

At the end of last week I was at a stage where I was convinced that the reason that I could not get my code to build under linux was an issue with the code itself, and not an environmental problem.

I was right.

At first I thought I'd just try to get a really small tutorial program building and gradually build it up to what Mod Wars doing but then I took another look at my code and asked myself "what's the difference here?" Suddenly I saw it - all of my code is enclosed within namespaces and of course none of the sample or tutorial programs were.

The errors I was getting indicated that the wxWidgets classes were not being recognised. There is a macro that has to be used for each class such as DECLARE_APP(class_name) for the application class (which encapsulates main), and these macros lie outside of the class in most cases. In my code I had them outside of the class but within the namespace. I tried moving them outside of the namespace and the code built. Ahhhhh relief at last!

I still have one remaining issue on Linux but it's a minor thing. I am using one of the additional SDL libraries, SDL_gfx and I was lucky to find it already installed and built for me but the library file has a .so extension rather than a .a extension like the others. All these libraries are in the same directory yet the linker could not find the .so one. The only way I could get it to build was to put in the absolute path which is a little annoying but not the end of the world.

I checked in my code changes, updated my Windows version and re-built from there to double check everything. Until this point I hadn't even tried a release build and I had to fiddle with a few project settings which I had not set properly for release. I did encounter one odd problem though. Under windows, I use precompiled headers but using the same settings, it built fine under debug but not release - it spat out a lot of errors about the pch file. The only resolution to that problem was to change the release version to not use precompiled headers. Thats fine actually because whenever I check in new code I like to do a full build anyway, just in case of inconsistences.

So, finally I have working code building on two platforms, cool! Oh, and here's a pic of my crappy grid:

No comments: