[Previous] [Contents] [Index] [Next]

Appendix: Using PhAB under Microsoft Windows

This appendix describes the main differences between the Windows and native QNX versions of PhAB.

Photon in a single window

Like the native QNX version of PhAB, the Windows version uses Photon and the Photon Window Manager (pwm) to manage its windows and dialogs. The main difference is that under Windows, Photon runs within a single window.

When you launch PhAB, it first starts a console window that it uses only for status messages. Next, the main Photon window is created. All PhAB windows and dialogs appear within this main window, and any sub-applications launched by PhAB stay within this window. Note that you can run multiple PhAB sessions within this single Photon window.

You can minimize application windows within the Photon window, but since there's no shelf application running, the right mouse button has been set up to list all running applications and to let you bring them to the foreground. To do this, simply click the right mouse button on a blank area of the main Photon window, then select the application you wish to bring to the foreground.

Exiting PhAB

When you exit PhAB, it attempts to shut down all Photon components as well, unless there are other applications still running within the Photon window (such as a second PhAB session or the language editor).

If all Photon components don't shut down automatically, or if you just want to force everything to exit in the event that the system is having problems starting PhAB or Photon components, you can type:

ph -kill

from a Windows command prompt.

Advanced options

If you wish to specify command-line options to pwm or to the photon server, you can use these environment variables:

You set these environment variables using the Environment tab (in the System program of the Windows Control Panel).

For details on the command-line options for any QNX utility, see the Utilities Reference.

Mixed-case filenames

When transferring a PhAB project from QNX to Windows, you may run into problems related to the case of the filenames. QNX and UNIX systems respect the case of filenames, while Microsoft Windows doesn't. This leads to these main problems:

DDD -- Data Display Debugger

DDD (Data Display Debugger) is a visual debugger that provides a graphical front end for GDB. You can download DDD for QNX cross-development on Windows from the experimental downloads section of http://qdn.qnx.com.


Note: Be sure to download the version that matches your current QNX Cross-Development kit.

For more general information on DDD, visit http://www.gnu.org/software/ddd.

If you've installed DDD, you can change the PhAB Preferences in order to use DDD as the default debugger (instead of the command-line version of gdb). You can use DDD outside of PhAB as well, simply by typing:

ddd -debugger ntox86-gdb ...

at a Windows command line.


Note: DDD, like PhAB, doesn't currently run under Windows 95/98/Me.

DDD is an X Window System application, which means that you need to have an X server running on your computer in order to display DDD. When DDD starts, it uses any X server that's already running. If none is running, then a simple default X server is started.


Debugger launch line

In PhAB's Build + Run dialog, there's an Advanced Options button that brings up the Build Preferences dialog (for more information, see the Generating, Compiling, and Running Code chapter). There you can specify the debug command that PhAB should use. The default debug command used by PhAB on Windows is:

gdb.bat -debugger nto$TPR-gdb --symbols

This runs the commands in the gdb.bat batch file.

If you installed DDD and you wish to run it as the default debugger, simply change the gdb.bat to ddd.bat and leave everything else the same.

PhAB automatically sets the TPR environment variable before issuing the debug command. It contains the name of the current target processor, as determined by the last build performed. Possible values are currently x86, ppc, mips, sh and arm. Having this variable in the debug command automatically selects the correct debugger executable for DDD to use.

Finally, since the Windows version of PhAB is never used for self-hosting, PhAB passes the --symbols option to GDB by default. This is like the symbol GDB command, and makes gdb load symbols from the PhAB executable without making it the program executed when you use the run command. This lets you run the executable on the remote target. Here are the initial commands from a typical debug session after DDD or GDB is started using the default launch line:

(gdb) target qnx com1
(gdb) upload myprog
(gdb) run myprog
(gdb) break main
(gdb) continue

For the above, we assume that we're connected to the target machine via serial port com1 and that the pdebug remote debug agent is already running on the target.

Resources control panel performance

The Windows version of PhAB takes longer to populate the Resources control panel than the native QNX version does. If the Resources control panel is displayed and isn't covered by another control panel, it's updated every time you select a different widget.

To eliminate this extra delay and improve the response time of widget selection, you may want to keep the Resources control panel covered by a different control panel until you actually need it.

Custom widget development and PhAB

Photon lets you create applications using widgets that you've built yourself or obtained from a third party. You can build these custom widget libraries into your application and run it on your intended target.

For documentation on writing source code for custom widgets, getting them to run within your application on the target, and getting PhAB to recognize your custom widgets, see Building Custom Widgets. The process for doing these things is essentially the same on all host platforms.

PhAB can dynamically load custom widgets and display them properly as you develop your application on the host machine. Before this was possible, you could set dimensions and specify resources and callbacks, but these settings wouldn't actually take effect and be displayed until you ran the application on the target.

To make PhAB display custom widgets correctly on the host as you develop your application, you need to take some extra steps that depend on the host platform. You need to recompile and link the custom widget source code for the host platform and processor. Under the QNX OS, this means building shared libraries that PhAB dynamically loads at runtime. Under Windows, the process is a bit different and is done using static linking.

Statically linking your custom widgets

For the following procedure, we assume that you've already performed the steps that aren't specific to the host platform. You need to:

After you've done all the above, follow these steps:

  1. Download and install the Cygwin development environment from www.cygwin.com. This is an open-source UNIX like system that offers a gcc-based development environment under Windows.
  2. Write a C function to act as PhAB's custom widget lookup table for all custom widgets. You must name it get_custom_wgt(), and it must check the passed-in widget class name and return the corresponding widget class pointer. For example:
    #include <Pt.h>
    
    extern PtWidgetClassRef_t *MyWidget;
    
    PtWidgetClassRef_t **get_custom_wgt( const char *name )
    {
    if (!strcmp(name, "MyWidget"))
      return &MyWidget;
    else
      return NULL;
    }
  3. Compile your custom widget functions and the lookup table function using Cygwin's gcc:
    gcc -c -D__LITTLEENDIAN__ -D__X86__ \
    -I /usr/lib/gcc-lib/i686-pc-cygwin/*/include \
    -I /usr/include \
    -I $QNX_HOST/usr/include -I$QNX_TARGET/usr/include \
    MyWidget.c get_custom_wgt.c
      
  4. Make a backup copy of the original ab.exe that was shipped with PhAB.
  5. Link your custom widget object files to create a new version of ab.exe:
    ld $QNX_HOST/usr/photon/appbuilder/ab.o MyWidget.o \
    get_custom_wgt.o -o ab.exe -lcygwin -lkernel32
      
  6. Replace the existing PhAB executable with the new one you've built. You must exit PhAB to do this.
    cp ab.exe $QNX_HOST/usr/photon/appbuilder/ab.exe
      

The next time you start PhAB after completing these steps, you should be able to see custom widgets displayed correctly as you work with them.


[Previous] [Contents] [Index] [Next]