|
Cross platform development By Peter Naulls. Published: 24th Sep 2004, 11:18:25 | Permalink | PrintableBuilding RISC OS Programs on Windows Perhaps surprising, and certainly not obvious to many people, is that it's been possible to develop RISC OS programs under Windows for a long time. Historically, ARM's SDK environment was able to generate RISC OS binaries, although that support was removed some time ago. More recently (but has still been true for a number of years), it's been possible to build RISC OS programs using GCCSDK under Cygwin - although bugs in the version of the compiler packaged with it did make that problematic earlier this year.
As long as you follow the steps correctly, it's straightforward to setup on any Windows system. The setup for Linux (or any Unix environment) is very similar, but it is worth illustrating how to do it on Windows because that is a system that many people already have access to.
Windows Development?
Why would we want to develop on Windows in the first place? Well, the reasons are similar to why we'd want to do it on a Unix system - access to much faster hardware for compiling large programs, and perhaps more importantly, a Unix style environment in which build systems are designed to run instead of spending large amounts of time on customised RISC OS build scripts and makefiles.
Under Windows, the Linux style environment is provided by Cygwin, which gives a Unix command line shell, build environment and generally a way to develop and run Unix programs under Windows. This is important, because GCCSDK, the development system for GCC for RISC OS needs precisely this environment in which to work.
Installing Cygwin
The Cygwin installer - downloaded from its home page - is reasonably straight forward. When running it, the default options are probably fine, and choose a suitable mirror (e.g. ftp://mirror.ac.uk/) for your location. If follow the installer through, it will give you a basic setup with a Windows desktop icon that launches a bash shell alongside other basic Unix utilities.
You should then rerun the installer, and add additional packages. I recommend this 2 stage approach because when I tried to do it in one stage, I found that some of the basic packages first time around were missed. In any case, you can rerun the installer as many times as you like to manage installed packages.
On the package selection dialogue, open the 'devel' tree view. You will want to make sure you install the following packages: autoconf, automake, binutils,
bison, cvs, flex, gcc, gcc-core, gcc-g++, gperf, make. These tools are sufficient to build GCCSDK itself, but it's possible you might want to install others later to help build programs for RISC OS.
Building GCCSDK
The first step in building GCCSDK is to check it out of CVS. To do this, first start Cygwin, which will give you a bash shell in a terminal window. The CVS checkout process is outlined on the GCCSDK home page, but the exact commands you will need are:
cvs -d:pserver:anoncvs@gccsdk.riscos.info:/usr/local/cvsroot login (enter 'anoncvs') for the password cvs -z3 -d:pserver:anoncvs@gccsdk.riscos.info:/usr/local/cvsroot co gccsdk
All going well, the GCCSDK source will download and will now be accessible. The instructions on building GCCSDK are detailed in its README, but again, the exact commands you will now need are:
cd gccsdk autoconf; autoheader sh do-configure make setup make
On a fast PC this might take around 10 minutes or less. Note that the version of GCCSDK you're building is the current development version, which means there's a small chance it might not build at all, or it might exhibit issues. In practice, however, this has rarely been the case, and is in most cases recommended because of on-going improvements and bug fixes.
Using GCCSDK
If the above step went successfully (and if it didn't, the GCCSDK team would be keen to know), then not only will you have built yourself a RISC OS cross compiler, but if you look in /home/riscos/ (or C:cygwinhomeriscos), also RISC OS applications including !gcc, which you can copy directly to a RISC OS machine over a network (GCCSDK adds ,xxx filetypes to the filenames so the correct RISC OS filetypes are presented over LanMan, NFS, etc).
So what we have now is not only a way to build GCC for RISC OS itself, but a cross platform development system. Let's give it a whirl with a simple program:
#include
int main(void) { puts("Hello RISC OS!"); return 0; }
Which is saved into your cygwin home directory as 'hello.c'. I can then type:
/home/riscos/cross/bin/gcc hello.c
And out should pop a file !RunImage,ff8 which is a program you can run on your RISC OS machine. And that's really the whole basis of cross compiling - the ability to construct programs on a different system.
More Interesting Behaviour
The real power of this system becomes evident if I can do something that's much harder to do on RISC OS. Compiling a simple C program is all very well, but that's easily done on RISC OS - sure, it might take a bit longer, but not too much has been gained. To demonstrate what can be done, some additional programs need to be installed, in the shape of my porting tools scripts.
If you have wget installed in Cygwin (or download the source with a browser instead), you could do something like this:
cd wget http://www.riscos.info/porting/scripts.tgz cd /home/riscos/ tar xfvz /home/Peter/scripts.tgz cd
The program I've chosen to demonstrate with is one we've just used - wget. I've chosen it because it has no special build requirements and doesn't rely upon extra libraries. I'll use the cygwin version to fetch its source:
wget http://ftp.gnu.org/pub/gnu/wget/wget-1.9.tar.gz tar xfvz wget-1.9.tar.gz cd wget-1.9
wget's build system is GNU Configure, which is probably the most widely used of Unix build systems. It provides a 'configure' script which is run directly (sometimes with options) to determine the capabilities of your system and construct suitable makefiles. If for example I wanted to recompile wget for Cygwin, this is what I would do. However, for cross compiling, the situation is rather more complex - it has to be told where the cross compiler is, where libraries are and system capabilities that it's not able to determine because it's not running on the target system. In total over many programs, these can add up to several hundred different options that might need to be set.
Fortunately, I've already done all the hard work for you, and I've provided a wrapper script that examines a program's configure script and passes it appropriate options to build for RISC OS. You can invoke it simply:
/home/riscos/env/ro-config
After this completes, you'll then be able to build it. Sometimes, just running 'make' is sufficient, but often this doesn't work correctly for a variety of reasons. Because of this, there's also a make wrapper:
/home/riscos/env/ro-make
Finally, once this builds, you will have a wget,ff8 binary inside the 'src' directory, which you'll find works just fine on RISC OS.
Going Further
Whilst there are plenty of programs that are as simple to build as wget, there are many more that aren't. The main stumbling block is libraries - and whilst it's certainly possible to build them yourself, it can be a bit of effort ensuring you have all the correct options and have massaged build files appropriately so that they cross compile correctly. To expedite this process, you can instead download my pre-built libraries. The tgzs provided need to be unpacked into /home/riscos/env/.
Other Systems
As I mentioned earlier, GCCSDK works perfectly will under x86 Linux, this being the system on which it is mostly used, and equally well under other Unixes such as the BSDs. Where it won't work currently is big endian systems - this includes MacOS X, and Sparc machines because some of the tools in GCCSDK aren't yet fully aware of endian swapping. The good news is that this is currently in the process of being resolved.
More on RISC OS compilation
Although the example I've mentioned here, and where much of the power of this system is relies in building ported programs, it's certainly possible to build RISC OS specific programs too. I'll not go into the details here, but libraries such as DeskLib and OSLib can be used (and themselves built) in such an environment, and the NetSurf browser is also developed in this manner.
Rounding off
I hope I've given you a taste of what's possible - it's in this sort of environment that most of my ports are developed (although I use Linux on an ARM machine). I made a recent post to the GCCSDK mailing list about future developments, which you can read here. If you have any comments, or suggestions on improvements, then feel free to subscribe to the mailing list and contribute.
Links
GCCSDK
Cygwin
RISC OS Porting tools
RISC OS Libraries
wget
Previous: ArtWorks 2.3 slated for Guildford show release
Next: German RISC OS meet
Discussion Viewing threaded comments | View comments unthreaded, listed by date | Skip to the endPlease login before posting a comment. Use the form on the right to do so or create a free account.
|
+++ Message board +++
Read messages or start a new thread
Search the archives
Today's featured article
RiscPC breaks 1.5GHz barrier Calm down dear, this is a case mod
23 comments, latest by flypig on 13/5/04 1:56PM. Published: 12 May 2004
Random article
RISC OS overtakes Apple in the Open Directory
2 comments, latest by beebware on 4/8/01 10:44PM. Published: 21 May 2001
Login
Create a new account
Forgot your password?
Useful links
News and media:
Iconbar •
MyRISCOS •
ArcSite •
RISCOScode •
ANS •
C.S.A.Announce •
Archive •
Qercus •
RiscWorld •
Drag'n'Drop •
GAG-News
Top developers:
RISCOS Ltd •
RISC OS Open •
MW Software •
R-Comp •
Advantage Six •
VirtualAcorn
Dealers:
CJE Micros •
APDL •
Castle •
a4 •
X-Ample •
Liquid Silicon •
Webmonster
Usergroups:
WROCC •
RONE •
NKACC •
IRUG •
SASAUG •
ROUGOL •
RONWUG •
MUG •
WAUG •
GAG •
RISCOS.be
Useful:
RISCOS.org.uk •
RISCOS.org •
RISCOS.info •
Filebase •
Chris Why's Acorn/RISC OS collection •
NetSurf
Non-RISC OS:
The Register •
The Inquirer •
Apple Insider •
BBC News •
Sky News •
Google News •
xkcd •
diodesign
|