CrossKylix
Sponsor:

Viprinet Multichannel VPN Router allows bonding of up to six ADSL lines

The Viprinet® Multichannel VPN Router™ lets you bundle up to six physical broadband lines like ADSL into a single virtual dedicated line.


Really new stuff: Yes, even in the year 2017, CrossKylix still is used and actively maintained by the author. 13 years anniversary \o/. And it now even supports installing it into recent (Unicode-based) Delphi versions up to 10.2 Tokyo.

Not-so new stuff: In late December 2012 we finally published CrossFPC, which integrates FreePascal as a cross-compiler inside the Delphi IDE. Using that, you may target various platforms including 32 Bit Linux. While CrossKylix still is used by many, unlike it the CrossFPC project actually has a future. Go check it out!

Old stuff: In February 2007 I wrote: A cross platform vision for Delphi - a detailed analysis and proposal on how CodeGear could increase Delphi's market share again by integrating a cross-platform compiler into the Delphi/BDS IDE. Old, but still an interesting read, especially as some of my ideas from back then finally appear to get implemented.

CrossKylix - Kylix Crosscompiler for Delphi/Windows

About

Welcome to CrossKylix, a free toolkit to integrate the Borland Kylix (Delphi for Linux) compiler into the Delphi Windows IDE.

This project was created for people who wish to develop cross-platform applications with Delphi, without the need to switch between Linux/Kylix and Windows/Delphi all the time. The project is best suited for usage in web applications, packages and components, but crosscompiling of visual CLX projects is also supported.

Up until now developing cross-platform with Delphi required you to have a seperate Linux installation (either on a dedicated box or inside VMWare) to recompile your project for the Linux platform. With CrossKylix this is no longer needed - you are able to build your project using the Kylix compiler from directly inside your Windows Delphi IDE, without the requirement of a local Linux system. Sounds cool? Read on...

Features

CrossKylix has the following features:

  • Allows you to compile native Linux applications from inside the Windows Delphi IDE
  • Console projects, packages and visual CLX applications are fully supported
  • CrossKylix is perfectly integrated into the Delphi IDE - you will get compile warnings, hints and error messages, and be able to jump to the lines in question by clicking on the message pane the same way as with the internal Delphi windows compiler
  • Makes Kylix Application deployment easier than ever - no need to install Kylix shared objects to /usr/lib, no need to create startup scripts for your Application
  • Very high Linux emulation speed - low compile times
  • A command line compiler (ckdcc) is included for you make-file loving folks
  • It automatically fixes the Kylix exec-shield bug during compilation
  • It's free! :)

How it works

Of course CrossKylix isn't a real cross compiler. The only ones able to build a real cross compiler would be Borland themselves. Instead the official Kylix command line compiler is used in an emulated Linux environment. To do that, CrossKylix implements a loader for the Linux ELF binary file format. Once dcc is loaded into memory, it is executed in a debugger-like way, translating all Linux syscalls to native Win32 functions. To achieve this it wasn't needed to write a "real" Linux emulator, it was enough to emulate the memory functions and Linux syscalls needed by dcc and the shared objects it loads.

Prior versions of CrossKylix used to be based on the LINE project, which emulates Linux syscalls through the Cygwin Linux emulation layer. As Cygwin is a buggy beast, this caused quite a lot of frustration on my side, and gave CrossKylix several limitations. By rewriting the emulation engine in native Win32 code, LINE and cygwin and with them all those problems are now history.

Next step was writing a Delphi IDE plugin to integrate the compiler. This plugin adds "Build with CrossKylix" and "Compile with CrossKylix" items to the Project-menu. During compile, it also parses the output of the Kylix compiler executed in the background to give out Hints/Errors to the Delphi messages window - clicking on those brings you to the source file at the correct line, like it uses to be in Delphi. So after all, integration is pretty tight - not much difference to compiling for Windows. One limitation exists: You can't directly run or debug the compiled linux executable.

As a special bonus after CrossKylix installation a patched version of Libc.pas is created. If you use this version of Libc.pas in your projects, most of your Kylix application deployment issues will be history. More about this below. Also a bug in the Kylix compiler which crashes your Kylix applications when run on exec-shield enabled systems is fixed automatically.

Now you know how it's done. Let's go test that beast.

Requirements and Download

The following things are needed to use CrossKylix:

  • Installed Delphi 6, 7, 8, 2005, 2006... etc including Delphi XE10.2 Tokyo
  • Kylix 3 installation CD (CrossKylix is tested with Kylix 3 Enterprise and Open Edition)
  • Windows 2000, XP, Vista, 7, 8 or 10 (Windows 95/98/Me won't work)

Download CrossKylix Version 1.1.2, June 22th 2017, 1.2MB

Installation

Starting with Version 0.9.0, setting up CrossKylix is pretty easy. Please follow these steps:

1. Download and run the CrossKylix installer

Well, yes.

2. Insert your Kylix 3 installation CD

Next we need to install the Kylix files (binaries, libs and units). At the end of the setup program, you are automatically asked for this. You may also cancel the dialogue and start the "Installkylix" tool at a later time, if you prefer. The installer will prompt you for your Kylix 3 installation CD, unpack and install all required files, and then create a patched copy of Libc.pas (see below).

If you only got an ISO file of a Kylix 3 installation CD, use DaemonTools or something similar to mount it.

CrossKylix also works with the Open Edition of Kylix 3. It's no longer available for download, I guess. If you happen to find a copy, unzip the tar.gz file using Winzip (or another packer) to a directory of your choice, extracting the path names too. Now inside the InstallKylix tool just browse to the directory you've unpacked Kylix 3 to and it will work.

3. Install the ide-plugin/expert

Fire up your Delphi, open <Installation path>\ideplugin\crosskylix.dpk, compile and install. You should see two new items in the Project menu, and a new menu item in the tools menu. After package installation, the CrossKylix options dialog should pop up. Browse to your CrossKylix installation path, so the label says "OK!". Hit OK, and you are done.

4. Test it

Write a little hello world command line application, save it, and compile it under Windows. Now hit "Build with CrossKylix". The IDE-Plugin should be converting your projects .cfg file to a linux dcc .conf file, and then execute the compiler. If everything went correctly, you'll end up with a linux binary in your project directory. If not, recheck everything, and have a look at the generated .conf file.

Have fun testing!

Hints & Limitations

Here are a few hints and tips for using CrossKylix:

  • While this seems obvious, it's often not noticed by new CrossKylix users: CrossKylix can be configured using Tools / CrossKylix options inside the Delphi IDE
  • When changing Delphi project settings, always save the project before compiling with CrossKylix, else the .cfg file won't be regenerated.
  • Remember you need to program in a cross-platform way. Make sure you never use absolute paths in your uses clauses. Third-party-components without source usually have different dcu's for Kylix and Delphi. Best practice for path management is: Add all Windows-specific unit search paths to Tools/Environment Options/Library. Add all Linux-specific unit search paths to Tools/CrossKylix options. Add all project specific search paths that use source compatible with both Linux and Windows in Project/Options/Directories&Conditionals.
  • If you encounter a compiler error like "Unit identifier 'bratwurst' does not match file name", you probably are suffering from this: While CrossKylix internally translates all paths to windows format whenever a file is accessed, the Kylix dcc compiler expects file paths to be in linux format inside the source files. If you use relative or absolute paths inside your projects, for example uses bratwurst in '..\bratwurst.pas';, CrossKylix will access the file just fine. But for dcc, the only valid path delimiter is '/' (forward slash), as it is under Linux. So the example given will result in dcc thinking the unit name is '..\bratwurst', which will fail to compile. So: For projects you are compiling with CrossKylix, always make sure you use forward slashes, e.g. uses bratwurst in '../bratwurst.pas'; in your source files including the project file. Luckily the Windows compiler also accepts forward slashes as a valid path delimiter, so you do not have to use IFDEFs to seperate between Linux and Windows - just always use forward slashes in path names inside your sources.
  • CrossKylix includes a command-line compiler, ckdcc. You'll find it in the CrossKylix installation directory. Usage is the same as with the original dcc compiler under Linux.
  • Space characters in path names are evil and often the root of all kind of problems. The background to this is that Linux uses a totally different way to "escape" space characters. Under Windows, if you use spaces in path names, you usually surround them with double quotes to get them accepted as a parameter. This does not work under Linux. Under Linux space characters are used by putting a backslash (\) in front of each space character. As you know, \ is used as a path seperator under Windows, so it's more or less impossible to translate this between both worlds. When compiling projects using the CrossKylix IDE plugin, paths that contain space characters will be translated using the good old short path name API (you know, those Micros~1 kind of names). This doesn't work for ckdcc, the command line version of CrossKylix. Basic thumb of rule: Installing CrossKylix to a directory that has spaces in its name is ok, but if you plan to use the command-line compiler, the projects you are compiling should be placed in a directory without spaces.
  • If you find a bug, turn on CrossKylix debug message in CrossKylix options and write me a bug report

Version history

Here is a list of recent changes to the project:

1.1.2 06/22/2017

  • Made the IDE plugin compile with Unicode based Delphi versions - 10.2 Tokyo confirmed to work

1.1.1 11/21/2016

  • Made the IDE plugin compile with XE2+
  • Search paths with a total length of more than 1024 characters are now supported (before CrossKylix would produce broken .conf files)
  • crosskylix.ini is now stored in the user application data folder instead of CrossKylix' bin directory

1.1.0 07/21/2010

  • A fix in regards of GetThreadContext makes CrossKylix now compatible with Windows 7 (and probably Windows Vista which before also didn't work, but I've never tested Vista)
  • An annoying bug (probably a Kylix compiler bug) that caused the first error message in a unit to be displayed inside the IDE in a garbled way, making code nagivation by clicking on the error impossible, is fixed. Finally, this was stealing my nerves for the last 6 years.

1.0.0 10/27/2004

  • Added "output directory" to CrossKylix options
  • Moved Kylix-paths to the top of the .conf file. This fixes the problem that if "Use Debug DCUs" was enabled in Delphis project options, Kylix tried to use those dcus (which failed). This used to be a common problem for many first-time users.
  • Added missing translation for -LU switch, which made compiling packages fail
  • Compile dialog now uses FileCtrl.MinimizeName to shorten the path name displayed - looks better
  • The CK menu items now will only be enabled if you have a compilable project open. For Delphi 2005 it will only be enabled if the current personality is set to Delphi.
  • The ckdcc command line compiler now will display some own usage information additional to the native dcc one
  • ckdcc now also works when installed into a path with a space character in it. Compiling projects with spaces in their paths still is begging for trouble, though.
  • Delphi 2005 now is officially supported

0.9.1 10/08/2004

  • A bug in ekemu.pas made CrossKylix fail when installed in directory with a space in it. Thanks to Alan for finding this bug.
  • When compiling from inside the Delphi IDE, the ck.dat process wasn't freed. Thanks to Ghislain for the notification.

0.9.0 10/07/2004

  • Finished a complete rewrite of the emulation engine. Everything now is native Win32 code, LINE is gone, and that crappy cygwin1.dll isn't used anymore \o/
  • The outer part of the emulation engine has been moved to Delphi code, and now resides in the ckemu.pas unit. The only stuff still written in C is the Linux ELF loader code and some syscalls implementations.
  • Changed form positions to poScreenCenter for better multi-monitor support (thanks Craig)
  • Added the option to output a full trace of all linux syscalls done by DCC. This is for debugging purposes, and hell slow.
  • A command-line compiler, ckdcc, is now part of the project
  • Added all the missing locale-stuff. CK is now able to compile source files that use characters outside the ANSI set, e.g. german umlauts. In the CK Options dialog it's now possible to select the source encoding. The default, ISO-8859-15, should be fine for western europe and the USA.
  • As reported by Kristijan (Thanks!), my Libc dlopen workaround did not work on Debian distros. This is now fixed.
  • As recently reported, Kylix compiled applications crash on Linux kernels with exec-shield enabled. I've provided a fix for this at http://crosskylix.untergrund.net/execshield/. This fix now automaticly is applied in-memory on CrossKylix-compiled executables, so you are no longer affected by this Kylix compiler issue.

0.8.2 07/30/2004

  • Fixed a bug that was causing CrossKylix to hang if dcc did output a lot of error messages while compiling a project
  • The installkylix.exe installer did not install optional packages like dbexpress
  • Now uses the GetShortPathName API call for getting short path names for paths that contain spaces. CrossKylix should now work for projects with spaces in path names. Also installing CrossKylix to a directory with spaces in it should be fine now. Thanks to Jim Mckeeth for the idea.
  • The strange cygwin1.dll bug that requires a lot of CK users to do a minimal Cygwin installation still isn't found or fixed. Sigh.

0.8.1 07/06/2004

  • Finally found out what was causing the Access Violations when closing Delphi and also caused the missing Tools menu item after restart - this is caused by adding the CrossKylix menu item at the end of the tools menu. Sigh. Now the item is added in the upper part of the tools menu, and it works. Open Tools Api sometimes can be a real mystery...
  • Added $WARN UNSAFE_TYPE OFF/$WARN UNSAFE_CODE OFF for D7
  • Project files with "unit1 in 'unit1.pas'" had problems finding unit1.pas, as Delphi/Kylix does not use the unit search path in this case, but uses the current directory. WHY? Added work-around to line/linexec
  • If dcc inside CrossKylix crashed for some reason, it kept stuck in an endless- loop causing also the Delphi IDE to freeze. It should now abort correctly in this case

0.8 07/03/2004

  • Now uses GetCurrentProject to find out active project.
  • Sets LANG=en_US
  • Added Andreas Hausladen's ProcessAffinity stuff to make LINE SMP-compatible
  • Now adds Kylix bin path to LD_LIBRARY_PATH so that libtextform.so can be used (so that text xfm/dfm files work with CrossKylix)
  • Tons of fixes to the line/linexec stuff to workaround a cygwin bug preventing the usage of libtextform.so
  • Now uses better buffering for stderr and stdout, resulting in no more messed up error/warning messages
  • Fixed a strange bug that was causing the stack to overrun, resulting in CrossKylix silently stopping to compile for a lot of projects (including all CLX stuff)
  • If exe and unit output directorys are not configured in project options, add project dir as default (no more "where is my exe?" bug reports ;)
  • Added the option to use a patched Libc.pas, which loads .so's from the application directory = much less hazzle deploying kylix applications
  • Fixed lots of bugs. Surprise, surprise.
  • Fixed a bug that sometimes gave an Access Violation when removing/recompiling the IDE plugins

0.7 06/08/2004

  • Removed int80.sys
  • Removed patchdcc.exe
  • Added path translations to linexec
  • Fatal errors are now displayed as errors in compile dialog
  • Compile dialog is now StayOnTop
  • Error box if unable to create configuration
  • Forced CrossKylix path to include a trailing backslash
  • Fixed problem that could result in an AV instead of displaying the CrossKylix options menu item under Tools
  • Added cfg filters for new Delphi 7 compiler directives not supported by Kylix (please report if there are more)

Kylix application deployment

As you may know, deploying Kylix applications (especially visual CLX stuff) to another Linux box can be quite some frustrating work. Please read efg's computer labs excellent report for more information on this.

The biggest problem with deployment is: Unlike on Windows, the system loader does not load libraries from the program installation directory. The .so libraries required by Kylix need to be placed in /usr/lib (or /lib). The only alternative up to now was to create a shell startup script for your program which would add you programs path to the LD_LIBRARY_PATH environment variable - ugly. If you don't have root access to the Linux server (for example if you use shared hosting), you usually are lost - only the root user may install new libraries, and most system admins will tell you to take your Kylix app and go away.

CrossKylix also offers a solution to this: When installing Kylix using installkylix.exe, a patched copy of Libc.pas (the main linux system unit for Kylix) is create in c:\crosskylix\libc. Under Linux, the libc function dlopen does the loading of shared objects (libraries). This function is declared in Libc.pas. In the patched version (called ckLibc.pas) this function is extended - if the standard way of loading a library does not succeed, it will now do a second attempt, using the path the running application is running in.

What this means is: If your application is using the patched Libc.pas, you may now simply place all required .so files (usually libborqt-6.9.0-qt2.3.so + dbexpress drivers etc) into the directory your application is installed to - and that's it! No more startup shell scripts, no copying to /usr/lib and running ldconfig etc...

The patched file ckLibc.pas is tightly integrated into CrossKylix. If you wish to use it together with CrossKylix, all you have to do is to check the "Use Libc.pas replacement for easy deploying" checkbox in the CrossKylix Options - that's it. CrossKylix in future will now automaticly add the search path c:\crosskylix\libc\ to your CrossKylix projects, and create a unit alias Libc=ckLibc". You don't have to change a single line of code, and all third-party components also will keep working as before (the Libc interface section isn't changed, so there is no need to recompile the whole RTL/CLX).

Credits & legal stuff

  • CrossKylix is written and copyrighted by Simon Kissel. It is licensed under the BSD License. In short this means: You may use CrossKylix to compile any kind of project without limitations. If you wish to modify and redistribute CrossKylix code itself, you are allowed to this, too. I'd really prefer if you send me changes and improvements you have made so other users can benefit, too.
  • The CrossKylix ZIP comes bundled with several Linux shared object files (glibc-2.2.5). Those are unmodified binary versions taken from the SUSE Linux distribution. They are licensed under the GPL. Following the GPL rules, the sources of the RPM package used are available for download here. This package is not needed for CrossKylix, it's just available for download to follow the GPL license.
  • InstallKylix.exe, which is used to install the Kylix binaries from the Kylix installation cd, internally uses tar32.dll, which is written by Yoshioka Tsuneo and is in the public domain.
  • Borland Delphi and Borland Kylix once were commercial products by Borland. No files copyrighted by Borland are shipped with CrossKylix. Kylix sadly is not available for purchase anymore.

Delphi and Kylix are registered trademarks of Borland Software Corporation. This project is not affiliated with Borland.

Feedback

As I'm a very busy guy, please only mail me if absolutely required. I do not give any kind of support, sorry. If you really need to contact me, here is my address: scamp@untergrund.net.

© Simon Kissel 2004-2017.