I guess it had to come sooner or later: A native build of gpredict for Windows XP is now available for download. And the worst part of it all is that I have built it myself. Why do I bother, I keep asking myself…
Building it was not trivial at all, I had to try several approaches before I ended up with a useful process. I will describe this process here.
First I’d like to mention that I gave up on cross-compiling at a very early stage. Although I have the mingw stuff installed on debian, I just couldn’t figure out how to use it properly.
Next, I considered using devcpp, but that too was out of my control, and I have no Gtk+ 2.8 libraries either. Moreover, taking into account that their last release was 5.0 beta in Feb 2005, I really didn’t feel want to rely on it.
So, what was left? Well, I googled a little and found out that another possibility would be to install MinGW and Msys, which provide the GNU toolchain as native win32 programs. It took me some time to figure out what the difference between MinGW and Msys is, and how to install them properly, but here is what I ended up with:
- Install MinGW. Default settings are OK.
- Install Msys, say YES to have MinGW already installed and let Msys replace Mingw-make. Also, specify C:/MinGW (or wherever you installed MinGW) when asked for fstab link.
- Install Msys-DTK (why? contents?)
- Install the Gtk+ libs and dev-libs from Tor’s page. These should go to C:/MinGW
- Install pkg-config in /bin. I don’t recall whether I had to modify some of the gtk*.pc files, but we’ll see next time.
At this point I have also created a directory for the gpredict run-time. The Gtk+ and other run time libraries and binaries should be put in /bin. Actually, the ZIP files do contain the correct path information, so try to keep that one.
After building a hello world, which worked, I could continue with gpredict. The strategy was as follows (heavily inspired by gaim):
- Create global-make.mingw that includes common flags and definitions as in gaim. We will also need a top level config.h.mingw
- Build goocanvas.dll
- Build sgp4sdp4.dll
- Build gpredict.exe
Of course, all these will require an appropriate Makefile.mingw containing info on how to build DLLs, LIBs, and EXEs. The gaim package is really priceless in this context.
So, what happened? Well, it went all right, and here are som notes and comments from the build process:
- No comments…
- Goocanvas needs its own config.h (copy from linux build) as well as goocanvasmarshal.h and goocanvasmarshal.c – these had to be added to the build list, too. After doing that it builds just fine!
- No problems with the SGP/SDP library. It builds just fine creating both DLL and LIB.
- GPREDICT.EXE was a little more tricky due to missing gettimeofday(). I solved this by copying libc_internal.h and libc_interface.[ch] from gaim, and patched gtk-sat-module.c, time-tools.c, sat-log.c, and sat-pref-formats.c, whereafter I built the EXE without trouble. The same thing should be kept in mind when adding networking code later… Rule of thumb: Learn from gaim!
As for the run time environment, I got by very cheaply. I just created a directory and placed all the Gtk+ and gpredict stuff there, and created a ZIP package. When I’ll have some time later I may clean out a little. Right now it is more than 10 MB but I guess that’s not an issue nowadays.
So, that was the story of my gpredict adventures in windows. If someone comes to me in the future and tells me that he wants to maintain the win32 port of gpredict, I will not mind at all!