Elevate Software


Login Login

ProductsBulletSalesBulletSupportBulletDownloadsBulletAbout





Home » Technical Support » ElevateDB Technical Support » Technical Articles » ElevateDB and Lazarus Windows CE/Mobile Build Notes

Icon ElevateDB and Lazarus Windows CE/Mobile Build Notes

Published on Tue, May 25 2010
ImageWe already covered how to create a sample Lazarus application for Windows CE/Mobile in the following technical article:

Building a Windows CE Application with Lazarus and ElevateDB

Although this technical article covered the basics of cross-compilation, it didn't go into quite enough detail to make the whole process smooth for the developer that isn't already familiar with the Lazarus IDE. ElevateDB customer Richard Harding was kind enough to provide the following step-by-step set of build notes for cross-compiling ElevateDB applications for Windows CE.

Installing Microsoft Device Emulator
Visual Studio contains Microsoft Device Emulator which allows the emulation of mobile devices. If you do not have Visual Studio you can obtain the emulator from one of the following links.

Download Device Emulator 1.0

Download Device Emulator 2.0

Download Device Emulator 3.0

For the rest of this article, it will be assumed that we're using the Microsoft Device Emulator 1.0.

The next step is to obtain some Windows Mobile OS kernel image files. This can be obtained from the Windows Mobile 6 SDK. Download and install the setup from the following link:

Download Windows Mobile 6 SDK

The following link provides more downloads and information for Windows Mobile:

Windows Mobile Developer Center

Running and Configuring the Microsoft Device Emulator
Open a Windows command prompt, and type the following command to run the Device Emulator Manager:

\Program Files\Microsoft Device Emulator\1.0\dvcemumanager

Information All of the directory specifications mentioned here are for 32-bit versions of the Windows operating system. For 64-bit Windows, replace any mention of the Program Files directory with the Program Files (x86) directory.

Once the Device Emulator Manager is running, open the following node in the list of nodes under the main DataStore node:

Windows Mobile 6 Professional SDK

Under that node, select the following node:

Windows Mobile 6 Professional Emulator

and then click on the Actions menu and select the Connect option. This will start the selected device emulator.

Once the device emulator is running, execute the following steps:
Image
  • Click on the File/Configure option on the main menu. On the General tab, check the Specify RAM Size check box and enter 256 as the number of MB of memory. Then enter a Shared Folder, which allows you to copy files from your PC to the emulator.


  • Click on the Network tab and make sure that the Enable NE2000 PCMCIA network adapter and bind to check box is checked, and that the option is set to Connected network card.



  • Information You may be required to download and install Virtual PC 2007 in order to use the networking functionality with the emulator and the host Windows installation. Under Windows 7, however, this is a bit of an issue. See the following link for more information on installing the required network driver for Virtual PC under Windows 7.

    Windows Virtual PC and the Microsoft Device Emulator

  • Click on OK and wait until the Windows Mobile “desktop” appears.
Copying Files to Emulator
Copying files to the emulator is simple. In Windows, just copy the required application files to the emulator’s shared folder that you specified when configuring the emulator. Once the files are in the shared folder, use the emulator to copy the files from the shared folder to the desired folders on My Device by using the File Explorer (Start/File Explorer).

Configuration Settings for Lazarus
The following areas cover all of the configuration settings that must be made for your application in the Lazarus IDE. These notes assume that you have already installed the ElevateDB design-time package into the Lazarus IDE prior to making these changes.

Lazarus Winsock Bug

An error in the Lazarus/Free Pascal winsock.pp unit is documented at the following link:

0013614: Windows CE/ARM Winsock Unit Declarations Incorrect Due to Packed Records

so you must modify this unit for the Free Pascal 2.2.4 compiler run-time library. To do so, use the following steps:
  • Copy the:

    C:\lazarus\fpc\2.2.4\source\rtl\wince\winsock.pp

    unit to the

    C:\Program Files\ElevateDB 2 LCL-STD-SRC\Lazarus (WinCE) 0.928\code\source

    folder.


  • Make the changes to the winsock.pp, as indicated in the bug report link above.


  • After you Build the Windows Mobile application, ensure that winsock.o and winsock.ppu have been created in your project folder.
Project Options (Project/Project Options)

The following project options should be set on the Miscellaneous tab:
  • Project is runnable - unchecked

  • Save .lrs files - unchecked

  • All other options - checked
Project Inspector (Project/Project Inspector

In the project inspector, remove the EDBRun (>=2.0) package from the list of Required Packages.

Environment Options (Environment/Options)

In the environment options, make sure that the following settings are correct:
  • Lazarus directory
    C:\lazarus\

  • Compiler path
    C:\lazarus\fpc\2.2.4\bin\i386-win32\fpc.exe

  • FPC source directory
    C:\lazarus\fpc\2.2.4\source\

  • Make path
    C:\lazarus\fpc\2.2.4\bin\i386-win32\make.exe
Win32-Unicode Compiler Options (Project/Compiler Options)

For 32-bit Unicode Windows applications, use the following settings.

The following settings should be present on the Paths tab. Where there are multiple lines, the lines should be entered as one line with semicolons used to delimit each setting.
  • Other Unit Files
    $(LazarusDir)\lcl\units\$(TargetCPU)-$(TargetOS)\
    
    $(LazarusDir)\lcl\units\$(TargetCPU)-$(TargetOS)\$(LCLWidgetType)\
    
    $(LazarusDir)\packager\units\$(TargetCPU)-$(TargetOS)\
    
    C:\Program Files\ElevateDB 2 LCL-STD-SRC\Lazarus (Win32-Unicode) 0.928\code\source\

  • Include Files
    $(LazarusDir)\lcl\units\$(TargetCPU)-$(TargetOS)\$(LCLWidgetType)\

  • LCL Gadget Type - win32/win64
The following settings should be present on the Parsing tab.
  • Assembler style - Default
The following settings should be present on the Code tab.
  • Target OS - Win32

  • Target CPU family - i386

  • Target Processor - Default

  • Optimization - Level 1
The following settings should be present on the Linking tab.
  • Strip Symbols from Executable - Checked

  • Win32 GUI application - Checked
The following settings should be present on the Other tab.
  • Custom Options - -dEDB_UNICODE
WinCE Compiler Options (Project/Compiler Options)

For Windows CE/Mobile applications, use the following settings.

The following settings should be present on the Paths tab. Where there are multiple lines, the lines should be entered as one line with semicolons used to delimit each setting.
  • Other Unit Files
    $(LazarusDir)\lcl\units\$(TargetCPU)-$(TargetOS)\
    
    $(LazarusDir)\lcl\units\$(TargetCPU)-$(TargetOS)\$(LCLWidgetType)\
    
    $(LazarusDir)\packager\units\$(TargetCPU)-$(TargetOS)\
    
    C:\Program Files\ElevateDB 2 LCL-STD-SRC\Lazarus (WinCE)0.928\code\source\

  • Include Files
    $(LazarusDir)\lcl\units\$(TargetCPU)-$(TargetOS)\$(LCLWidgetType)\

  • LCL Gadget Type - wince
The following settings should be present on the Parsing tab.
  • Assembler style - Default
The following settings should be present on the Code tab.
  • Target OS - WinCE

  • Target CPU family - arm

  • Target Processor - Default

  • Optimization - Level 1
The following settings should be present on the Linking tab.
  • Strip Symbols from Executable - Checked

  • Win32 GUI application - Checked
Building Lazarus Applications
When building Lazarus applications for Windows CE/Mobile, be sure to use Build All (Run/Build All) and do not run the application from within IDE.

Summary
Hopefully we've been able to give you a little better understanding of how to cross-compile Lazarus applications with ElevateDB. As always, if you have any questions at all, please feel free to post them in the ElevateDB newsgroup here:

ElevateDB General Support Forum

This will allow everyone to share in any new ideas or comments that you may have regarding this article.
Image