help files
Z505 | PasWiki | FUQ | Search | Main Docs | API Guide



Notes

The fpw.exe and fpwserv programs allow anyone on a Windows computer to create linux or bsd modern pascal programs transparently.. i.e. without the need to compile programs on an actual linux/bsd system in your home or office. You can immediately test the programs on a web server, and it offers advantages that cross compilers do not.

An early introduction video showing the first day the tool was tested is available here.

Not only MS Windows users, but Mac/Apple and Linux/BSD desktop users will also be able to use these tools too. We just happened to release the MS Windows copy of fpw.exe first.

Download

Version 0.0.2 early release is available.

Note: if you downloaded 0.0.1, please download 0.0.2 as there are readme updates included.

Out of over 1100 people who saw the video from the delphi community.. only a few people showed serious interest - and I now understand why kylix failed. There is not so much interest in Unix programming in delphi ;-)

Upcoming Advancements

Future versions of FPW/FPWSERV will be integrated further into delphi. Instructions how to setup text editors like EditPlus will also be given in details, so you can click on line numbers in your IDE. We will aim for the compiler messages to be click-able for line numbers in Delphi in future versions.

EditPlus and other editors can currently use fpw/fpwserv with clickable line info, but delphi not yet. The tutorial shows how to setup FPC but you can use the tutorial to setup FPW too.. as FPW acts just like FPC.

How To Use

Unpack the zip file first.

First place the fpw.exe program and fpw.cfg file in a directory that is located in your fpc.exe directory, such as:

  c:\fpc\2.2.0\bin\i386-win\
Then try executing the command in an ms-dos window:
  fpw.exe
(You can start a command line using RUN->cmd or RUN->command from start menu)

More instructions are included in the readme in the above zip file.

You can hook up the fpw.exe program to an IDE like Delphi or a text editor like EditPlus, Slickedit, Lazarus, Textpad, ConTEXT, PSPad, etc. FPW.EXE acts just like a freepascal compiler, but it has some other command line parameters as explained when you run fpw.exe in your console window the first time.

The tool will be improved so that it is easier to use with Delphi's tools menu (delphi doesn't like slashes near tools macros).

403 Forbidden? 500 Error?

If you have a 403 error, check to make sure the fpw.cfg file contains the correct settings on line 1 and line 2, and go over the readme file again to verify.

If you have problems such as 500 error you should check the permissions of your executables and directories on the unix server. You can change permissions using FTP. Some web hosting companies are picky about proper permissions.

On many servers, permissions must be set to 755 for fpwserv, ppc386, and fpc binaries.

On some servers, the permissions required are 777, 757, or 767. Check with your web host company to be sure.

Check also directory permissions for cgi-bin and subdirectories.

If you are not connecting to a web host company and you are connecting to an emulator or a server of your own, then check with your apache or web server setup on your system.

See also these mail archive posts

Other Server Issues

Some servers only execute binary files with a certain exension, such as *.elf.

Files without a specific extension are not executed on some servers.

You may need to rename "fpwserv" to "fpwserv.elf" or "fpwserv.cgi" and update the fpw config file on your Windows computer accordingly.

Linker Issues

If your server does not have "ld" (unix linker tool) on it then your program will compile but not link with fpc 2.0.4. Most servers have a linker on them. If you experience this problem try uploading a static "LD" to the directory where the compiler is being launched.

A static LD is one that doesn't rely on libraries:

You can open .DEB or .RPM files on windows using 7-Zip. However the tar.gz file above contains the ld_static binary so that you do not need to extract from a .DEB or .RPM file.

Put the ld_static program in same directory as PPC386 on your webserver, and renamed it to just "ld". It should work fine. Or you can try using your own copy of LD from some unix system or zip file you find. The static copy doesn't require .SO libraries and therefore may be easier for you to get running.

Setting Up IDE

Here is how to setup a simple test tools item in delphi ide:
Title: anything
Program: cmd
Params: /k fpw.exe programs/hello.dpr
Above should work as a test for you.

Ultimately you'd want to set it up like this:

Params: /k fpw.exe programs/$NAMEONLY($EXENAME).dpr
Above $MACROS won't work because of a slash problem (at least in delphi 5). Next release (0.0.3) will contain a workaround built into the fpw.exe program so the slash problem with delphi tools macros can be avoided.

Setting up other text editors is similar, and usually easier. Get to know the editors tools menu macros. Text editors do not have this slash problem, at least the ones we've tried.

How FPW Works

First you upload the fpwserv program to the server (typical CPanel or shared accounts are fine) and fpwserv handles everything for you on the server side. It needs to be uploaded with an FPC compiler and RTL, and fpc.cfg file (usually included and pre-configured with your copy of fpw/fpwserv)!.

Your desktop program, such as an IDE or text editor, invokes fpw.exe from a tools menu or a plugin. This fpw.exe program talks to fpwserv transparently, and acts just like a regular fpc.exe compiler. Instead of creating a windows executable on your computer, fpw.exe demands the server to create a web application. Your web application is immediately deployed on the server, from your offline IDE. Sounds tricky? It just works.

Once you have the IDE and server setup.. you only have to upload your project source files to the server when doing any web development, such as project1.dpr, unit1.pas, and unit2.pas.

It is similar to how you would upload PHP files to a server. However, with this system, you have strong typing, a real programming language, and an IDE like delphi, or a text editor. Many safety checks and type checks are done before the program goes live, whereas PHP would not offer these advantages (along with many security benefits in the API). Ultimately, it is much more powerful than php scripts since you can literally build any program you wish reusing existing delphi/fpc code and C libraries.

What is FPW and FPWSERV?

It stands for 'fp web' or 'fpc web'. Instead of launching fpc.exe, a program called fpw.exe is launched which magically connects to a program called fpwserv on the web server. The fpw/fpwserv system makes deploying high performance modern pascal web applications transparent for a Windows user, not even requiring a linux/bsd computer nearby in the home or office.

You could call it 'foopascal web' or 'freepascal web', if you like.

FPWSERV is the program that you upload to your typical CPanel or similar web server. FPW.EXE is the executable that runs on your Windows computer that talks to FPWSERV. It's kind of magic, and you don't necessarily need to know more intricate details of it.

Similarities to CrossFPC

The fpwserv and fpw.exe programs are more focused toward web development and server development.. specifically making it easy to deploy modern pascal code onto a typical linux/bsd web server. The server only needs to support cgi-bin or greater, and no shell or telnet access is required.

Some similarities exist between CrossFPC in that both projects aim to target FPC/Linux transparently.

Differences Between Cross Compiling

This is not a cross compiler.

Cross compiling on a Windows computer means that the Windows computer creates a unix executable with a Windows compiler. As we have previously written articles about cross compiling, some may find cross platform deployment options confusing, since there is more than one way.

FPW/FPWSERV demands the web server to create the executable and deploy it. The server feeds back information to your IDE about the ultimate progress of the deployment or compilation. Since deployment is immediate if there are no errors, your web program can be tested immediately in your web browser by going to the URL such as yoursite.com/cgi-bin/prog.cgi.

Differences Between FakeLinux

FakeLinux is not directly related to fpw.exe or fpwserv. FakeLinux is another way of creating unix executables on Windows, using a fairly fast linux emulator.

Basically, both fakelinux and cross compiling are not directly related to fpw.exe and fpwserv. There are many ways to create unix executables, but fpw.exe and fpwserv offer advantages over fakelinux or cross compiling.

In fact fpw.exe and fpwserv can even be used along with fakelinux as another powerful combination, but that is another topic (you can run fakelinux with fpwserv and apache on it for local testing of unix web apps, but it is not required since you can run fpwserv on a Cpanel or similar shared hosting account directly).

Differences Between Compile-Studio

Compile-Studio is an online web based editor for quickly testing and compiling programs.. kind of like how PhpMyAdmin is a way to quickly access a MySQL database. The fpw.exe and fpwserv programs are for hooking up your actual IDE or text editor to become a modern pascal web development environment.. whereas Compile-Studio is just a web based program where you edit and compile inside your browser.

Compile-Studio can be considered a gimmick or an emergency tool.. whereas fpw.exe and fpwserv are for professional offline IDE's. Compile-Studio is yet another way to make unix executables, not directly related to fpw.exe and fpwserv.

Differences Between... what next?

Lot's of options to create unix executables.. isn't there? Well we hope fpwserv and fpw.exe is the best way yet, to create unix executables. For example the best thing since sliced bread. However, it is still good news that there are plenty of options to create unix executables from a Windows system other than fpwserv and fpw.exe. Better yet, fpw and fpwserv can also be used on Macintosh/Mac and other operating systems too, we just haven't launched that part of the project yet.

Useful Tips

Since fpw.exe and fpwserv allow you to create and deploy web applications immediately on a real server that is publicly accessible, you will want to develop 'test' programs first that the public doesn't know about. Design your programs so that you do not hardcode any script names or program names into the program. Use relative paths where possible

For example create program1.cgi for testing, and deploy program2.cgi or program.cgi for the actual live public program. This helps if for example program1 still has bugs and you do not want hundreds of public traffic hammering your program while you are still developing it. You may be familiar with this technique if you have developed PHP code or similar. A lot of broken PHP scripts exist because the programmer is developing it live while the public is viewing it, which is not always good practice.

To avoid hardcoding strings into your program such as 'program1.cgi' simply use the pwenvvar.pas units. Use SERV.ScriptName to obtain the current executable running.. this is similar to ParamStr(0) in console programs.**

** In older copies of Powtils the unit was pwuenvvar.pas, while the script name was acceessible via CgiEnvVar.ScriptName

More Than Web Programs

The fpw/fpwserv tools can create more than just cgi programs remotely. Any programs could be created remotely on a server. For example say you have a web program that forks another non-web program... This non-web program can also be compiled remotely with fpw/fpwserv. This is more powerful than cron jobs because any web program can launch any program you like, or any program you build.. either as a background process or a child process.

Say you have a regular non-web program that you want to create for a cron job. So create a regular modern pascal program with fpw/fpwserv and use it.

The possibilities and power available with these remote tools are endless. You are not limited to just creating cgi programs or web programs.

Mac, Macintosh, Apple Desktop Users

We will of course be offering the tools to Mac/Apple users so they can develop web applications or server apps on linux/bsd easily.

Someone send Mac hardware for testing, to the developer please?
Email: L AT z505 . com

My relatives have a Mac that I can test on, if I don't end up getting one ASAP. Or I can buy one at a high price (fat chance). I you have urges and want this Mac business taken care of now, send me your Mac by postal mail right now. That would be the motivation that would send me to cloud nine.

Windows Desktop to Windows Server

This is possible too if a copy of FPWSERV for windows is put on a windows web server. The advantage of this would be that one could deploy the web app directly on a Windows server without compiling first on a local Windows box. Small advantages, maybe not so important. Haven't worked on this yet, but yes it is of course do-able.

More Documentation

This fpwserv/fpw.exe technology is bleeding edge.. just invented.. so not much documentation is currently available. As you can see, that is being worked on here on this page.





lufdoc, Powtils, fpc, freepascal, delphi, kylix, c/c++, mysql, cgi web framework docs, Z505