Friday, December 10, 2010

Use the migration from Windows Kylix3 to Linux

Introduction to use like Borland? Delphi7? Studio tools such as DB2 and IBM?? UniversalDatabase? the superiority of this database is the one, the migration between platforms only requires a small change and a recompile.

In this series of articles in the first article, I use Delphi7Studio creates a connection to the IBMDB2UDB application, in my second article, I will give this application adds more features, such as subordinate structure (master-detail) forms of reporting in order to make it more interesting and useful. Now that I've created an executable application, let's move on and to a large crossing, use BorlandKylix? 3 it from running on a Microsoft Windows on?? Delphi7 applications into Linux? application. Use Kylix3 is fairly easy to migrate to Linux, Linux BorlandKylix3 is a rapid application development environment. Kylix use Delphi7ObjectPascal (and c++) as a development language, and uses for Linux to familiar RAD environment. Borland tools provide one of the biggest advantages is that the migration of an application is "transplanted" project, than recompile Windows/Delphi (or Linux/Kylix) project. When using Kylix recompile applications to be migrated from Windows to Linux and Delphi7, there are several points to keep in mind. First, all versions of Kylix contains TSQLClientDataSet component, the component also Delphi6, but not in Delphi7 encourages the use of it and replaced it TSimpleDataSet. Although it seems not a big problem, but once you realize that it is a problem, this means that you can only use Delphi7 compile TSimpleClientDataSet, but can only be used in addition to other tools Delphi7 compile TSQLClientDataSet. applications from Windows to Linux to get the source files and move them from Windows to Linux file system. On Linux, the file name (and name) are case sensitive, so if you add some of your own cell, you must be careful (Delphi7 will ensure that all unit and file names are case-sensitive in the attention of named). However, you do not have to include all the project files from the transfer to Delphi Kylix in particular that is specific to Windows option of .cfg and .dof file. Kylix will put these files as a .conf and regenerate .kof file. In short, you only need the main project file (. Dpr and .res) and file (. Pas and .xfm) from Windows to Linux (this article uses code files can be obtained at the end of the article). DB2 on Linux, in addition to using Kylix on Linux, we also must connect to a DB2 on Linux version (of course, you can always and other platform DB2 database connections). A little tip: I've tried using DB2 Universal Database PersonalEditionv7.x, but encountered an error message: SQLError: Errormappingfailed. other use dbExpress and Kylix people have reported the news, in this case, just make sure on Linux using the most current version of DB2 (i.e. v8.1beta beta, available from the IBM Web site), you can solve this problem. A small amount of source code to change the source files from Windows to Linux, open a project in Kylix (see Figure 1). When you open the project and view the ObjectInspector SQLConnection characteristics, you will see two Win32-specific and cannot be used on Linux: LibraryName characteristic values (set to DBEXPDB2.DLL) and VendorLib (set to db2cli.dll). Linux is no DLL; it uses the .so file instead. To change these values, you must first select the ConnectionName property to another value, and then reselect DB2Connection as ConnectionName. This will bring LibraryName to libsqldb2.so.1 and VendorLib set to db2cli.dll. the good news is that when you drag items from the Windows of the Delphi to migrate to Linux on Kylix, simply change the two properties. The bad news is that must be performed manually. Whenever a platform for the new changes will have to manually perform these changes, this is not what you want done. Another good news is, in the form of the OnCreate event handler to write some code, and set the correct value to LibraryName and VendorLib (as well as the main form's Caption), we can solve this problem, as follows: procedureTForm1.FormCreate (Sender: TObject); begin {$ IFDEFMSWINDOWS} Caption: = ' '; SQLCOnne Delphi7talkingtoDB2usingdbExpressction1.LibraryName:='DBEXPDB2.DLL';SQLCOnnection1.VendorLib:='db2cli.dll'; {$ENDI} {$IFDEFLINUX} Caption:='Kylix3talkingtoDB2usingdbExpress';SQLCOnnection1.LibraryName:='libsqldb2.so.1';SQLCOnnection1.VendorLib:='libdb2.so'; {$ ENDI} cdsEMP_PHOTO.Open cdsEMP_ACT.Open cdsEMPLOYEE.Open;;; cdsEMP_RESUME.Openend; Note: we cannot simply first {$ IFDEF} then add {$ ELSE} because Linux is no longer the only alternative platform for MSWINDOWS, now Delphi7Studio (preview version for .NET command-line compiler) also support the CLR as a platform. Another you must check the features is's FileName property TSQLMonitor components, for example, it should not use the/, or \ characters, and should point to a file name. Finally, it should also be noted, MidasLib, dbExpDB2 and CrtL unit is not available on Linux, so you must use Midas.so and dbexpdb2.so library to deploy executables. When your Windows and Linux have a single source for the project, you can make in Delphi or Kylix (this causes the project source code for complex merge), or in an environment of work but only in another environment recompiled. Personally, I've been using Windows DelphiIDE design my application, and then bring it to Linux and Kylix recompiled. In this way, I can let the SQLConnection components point to the DB2 WindowsDLL (instead of Linux.so library). Closing with Delphi7 or Kylix3 and DB2, to build Linux applications, you don't have to because the tool or database availability and stranded at a certain platform, or sacrifice RAD environment. In my next article, I will combine dbExpress data access layer to use DelphiWebSnap components to build with DB2 back-end Web server application.

No comments:

Post a Comment