Rewriting for Linux?

Albert Cahalan acahalan at
Mon Apr 2 01:50:54 EDT 2007


> I have a fairly sizeable application, written in (Borland) C for MSDos,
> which I think might be useful if ported across to the XO.

Just C, or C++ with Borland's OWL library? Plain C is easier.

32-bit or 16-bit? Linux doesn't use the "far" keyword. Data types:

8-bit char
16-bit short
32-bit int
either 32-bit or 64-bit long (32-bit on this year's XO)
pointer same size as long

The struct layout differences may make old data files unreadable.
You may be able to cheat a bit by using #pragma or __attribute__
to make the Linux compiler match the Borland compiler.
See the compiler manual (URL below) for more info.

> It's entirely self-contained and self-running, but I can already
> see that I cannot hope simply to recompile its code into Linux !
> ( For one thing, all its display functions are writtten for
> 640 x 480 VGA.).

If you were writing directly to the screen, you might want to
convert your code to use the SDL library for graphics. That's the
easy way. The result will still be fixed-size though, 640x480,
unless you change that. Being resizable is possible, but SDL
won't give you any help.

For resizable conversion, you might use the GTK library. This would
let you make the program able to smoothly adapt to any screen size.
With GTK you lay out the screen in terms of geometrical divisions.
For example, you specify that an image gets the upper half of the
display and other stuff gets the bottom half. Then you subdivide
that "other stuff" area so that the bottom part is buttons and the
upper part is text. Then you subdivide the buttons area for the
individual buttons... but at this point you can probably use a
ready-made set of buttons rather than drawing your own buttons.
As you divide things up, you specify functions that will get called
when the various things get clicked, passed over with the mouse,
and so on. You write these functions to do as you wish.

> I am currently reading background material in order to teach
> myself Linux, but what I would like to know is what software
> you guys & gals are using to write and compile your code?
> Red Hat or what?

If you specifically wish to develop for the XO, then get the latest
version of Fedora from Red Hat. That will be easiest, because the XO
is running a slimmed-down version of Fedora. Any Linux will do though.
Get your program running on a regular PC before attempting to deal
with the XO; the XO has some quirks are aren't yet well documented.

Be sure to install the development tools. They are free, and are
on the CD, but won't always install by default.

The compiler is included. It's called gcc. Most people run gcc from
the command line, and run a separate editor to edit their code.
The compiler manual is here:
Be sure to enable warnings! The following are good options:
-O2 -g3 -W -Wall -Wstrict-prototypes -Wmissing-prototypes

I suggest that you install the editor called "joe". It's the one
that works the most like the one in Borland's Turbo environments.
The keystrokes are WordStar-like. Borland C supported that, as
well as the more common CUA style. If you like control-K to do
things, you need joe. If you select text with shift-arrow and copy
with control-C, then you prefer CUA and might like the nedit editor.

If you prefer an integrated environment (which contains an editor
and will run gcc for you) then you can try Anjunta, Eclipse, or emacs.
All are free, though they might not be installed by default.

Be sure to use the valgrind program. It just about automatically
finds many kinds of bugs.

More information about the Devel mailing list