I was really daunted with the prospect of re-building my Linux box, and worse, having to build ModWars on it, especially since I had three separate projects and several source files contributing to my glorious green square!
I started simply by building my common library which was only a couple of files and didn't depend on anything. That was fine. My client library complained about a missing SDL.h file but luckily SDL has been installed along with Fedora so all I had to do there was find it and then point the compiler to that directory.
The tricky part was installing the actual client app which relies on wxWidgets. I had not built a wxWidgets app on my virtual PC so this was new ground. It didn't build of course - it complained about the wx header file. I searched the packages and couldn't find one for it so I downloaded it. Now how to build wxWidgets on linux? I looked through the files that began with "install" but couldn't see anything obvious but gtk seemed familiar so I tried typing in the instructions in there. It complained about the development files for GTK+ being missing *sigh*.
So, I thought I'd check the package manager for it and searched for GTK. I was confused to find wxGTK in there already installed even though I had searched the entire machine for the header file I needed. I found the gtk development files so proceeded to install that but I was really confused now - what is GTK anyway and if wxGTK is installed then why can't I find the header file?
Once I downloaded and installed the GTK files two things changed. Firstly, I found an installation of wxWidgets. That struck me as odd because according to my package manager it was already there. Unfortunately it was version 2.6 but I figured that would do for now. In there was the header file I needed. But I also found that the configure program for the 2.8 version of wxWidgets which I downloaded now worked so I thought I'd try building it anyway. That took a while...
I'll give the install file credit - the step-by-step instructions worked without a hitch once the GTK files were present so I now had a wxWidgets 2.8 installation installed. So I added the include file to my directory list in Code::Blocks and tried again. This time the setup.h file wasn't found. I remember having issues with this before, I really should blog my problems and solutions to those problems more thoroughly!
After searching wxWiki I found an article about the setup.h file and how the build process generates it for you. So I did a search and sure enough I found one lurking in the build folder I'd just built. I copied it to the correct location and re-built. It got further this time but hit a #error message of "No target! You should use the wx-config program for compilation flags!"
In all the examples for compiling wxWidgets they show a command line version using g++ and part of the command line is "wx-config --cxxflags" and "wx-config --libs". I had no idea what these did and no idea how to reproduce the same effect in Code::Blocks.
I took another approach and tried creating a wxWidgets project using the wizard. That worked so I then deleted the source files and added my own. This time it got past the weird errors and whined about my application class saying "expected class name".
Some further searching on the forums finally revealed the correct way to use the wx-config options. Under build options for the project, I had to select the Compiler | Other Options and type in 'wx-config --cxxflags' and under the Linker tab in the "Other linker options" type in "wx-config --libs". Performing these two steps got me to the same place as I had in my test project with the same compilation errors.
I then managed to find a tutorial video showing how to build a wxWidgets application in Code::Blocks and found that the wizard I had used was nothing like the one used in this video. Some further searching revealed that I was using an old version. Could that be the problem I wondered? In Fedora there is an automatic package update utility so I clicked on that and it found an update to Code::Blocks (along with a squillion other things) so I let that do it's thing.
A very long time later Fedora finished updating, rebooted and sure enough I had a new version of Code::Blocks with a new wxWidgets wizard. It still wasn't the latest version though so I registered on the CB forums so I could download the latest one. Now I just had to install the linux version of 7zip so I could extract it, and then figure out what to do with it.
Once I did this it seemed to take me a step backwards. The default project would no longer build, complaining once again about wx-config. Worse still, I had now lost my option to enter in linker options and it was complaining about that also.I figured I had screwed things up and at this point I could see no option but to re-install CB from scratch.
This got me back to where I was before I watched the video. I could build the sample app, but not Mod Wars. However, i managed to find the linker options and fixed the wxconfig --libs line and I was also able to figure out how to link in my mw-common, mw_client_lib and the SDL libraries so this reduced the errors down a bit. Now all I had left were an undefined reference to main, and missing vtables for the other wx classes. I'm assuming the remaining issues are down to code and not project settings. Unfortunately I've run out of time so I'll have to leave this issue until another day.
Subscribe to:
Post Comments (Atom)

1 comment:
Linux development can be so infuriating at times, can't it... I've enjoyed the Java development that I've been doing at work, but one thing that puts me off wanting to continue it more than my C# .Net development is the issues around Linux. It really is awful to work with and when you get stuck like this, it's so hard to find the resolutions to your problems. When you spend days looking at these issues it really doesn't feel like productive development. Stick at it though, I'm sure you'll get that buzz at the end of it all.
You could do with some kind of knowledgebase to document all your issues and workarounds :)
Post a Comment