[fpc-pascal] Is Delphi7 on Windows to FPC on embedded Linux possible?

Michael Van Canneyt michael at freepascal.org
Sat Sep 25 11:41:34 CEST 2010



On Sat, 25 Sep 2010, Bo Berglund wrote:

> This may be a stupid question, but I just discovered FPC so please bear with me...
>
> I have been writing Delphi programs since 1996 or so (when Delphi 2 was released), so I am rather comfortable with that.
> Now I need to write for the Linux platform because we are trying to make a Linux front end to a piece of equipment we make that only has a pitiful character based LCD screen (8 x 20 characters).
>
> The front-end would consist of a small board with Embedded Linux and a graphical LCD screen (possibly with touch surface so the mouse can be dispensed with).
>
> Since I was told that Java is the way to go to get stuff working on several platforms I started to read up on Java but it is taking forever to get anywhere. :-(
>
> So then I found FPC and now I am looking for advice concerning if it would be possible to use FPC/Lazarus to program for an embedded Linux board with a graphics LCD screen. I want to be able to do the following:
>
> 1) Communicate via RS232 to the equipment core to control it and retrieve data. We already have a serial interface protocol for sending and retrieving data and commands, which would be the gateway into the core. So the first question is if there exists some class/component in FPC that can be used to communicate.

Yes, there are several classes.

>
> 2) Display control screens in a GUI way with standard controls (buttons, text boxes, radio buttons etc). This would be the new user interface for the instrument.

If you use Lazarus, this is possible, if you're running X11.

>
> 3) Display data graphically (curves, pie charts etc). We need to improve on the on-board datat display a lot....

There are several charting components available.

>
> 4) Store data on a file system, either SSD or flash memory.

As long as it is mounted, this is not a problem.

>
> Can this be done?
>
> Is it possible to program on a standard Linux distribution but compile for the embedded linux?

Yes. That's how it is done traditionally: cross-compiling. There is a FAQ floating around.

>
> Are there any traps to look out for?

Yes:
- Don't use Windowsisms.
   Use sysutils unit only. It is guaranteed cross-platform. 
- type all data strictly. 
- Avoid typecasting pointer to integer and vice versa.

>
> What is the best way to get started?

1. Install lazarus.
2. Take your existing Delphi units and start converting them.
    Lazarus has a tool for it :-)

>
> Can I even re-use my Delphi7 classes from the windows environment?

Yes, as long as they do not contain windows-specific code.
(in particular: the windows and ACtiveX units will not work on linux)

Michael.



More information about the fpc-pascal mailing list