This chapter can only be an introduction to such a large and varied subject as interoperability. There is a wealth of information on the Web and in particular on the Microsoft Web site with details about UNIX and
Migrating to Windows from UNIX and Linux, http://www.microsoft.com/windows2000/migrate/unix
Windows Interoperability, http://www.microsoft.com/windows2000/interop
Product Home Page for Windows Services for UNIX, http://www.microsoft.com/windows2000/sfu/
Microsoft Interix, http://www.microsoft.com/windows2000/interix/
Windows Services for UNIX version 2, white paper, http://www.microsoft.com/technet/treeview/default.asp?url=/TechNet/prodtechnol/windows2000serv/deploy/sfu/sfu.asp
Customizing Microsoft Windows Services for UNIX Installation, http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/windows2000serv/deploy/sfu/sfucustm.asp?frame=true
Windows 2000 Professional in a UNIX Environment white paper, http://www.microsoft.com/windows2000/library/planning/default.asp
Excerpts from the Windows 2000 Resource Kits, http://www.microsoft.com/windows2000/library/resources/reskit/default.asp.
This chapter describes how to create a development environment for application migration. First, it describes some of the tools and facilities that are available. Then, in the three main sections, it describes how to:
Configure the development environment.
Populate with source code and build structures.
Use the development environment.
The decisions made while setting migration strategy will help to define the development environment. This environment is either native Microsoft Win32 application programming interface or Microsoft Interix.
Solutions in this chapter use the Microsoft Visual Studio development system for Win32 source editing, for builds, and for makefile-based batch builds. Solutions use Microsoft Visual SourceSafe version control software for source control. Interix solutions use the Microsoft Visual Studio for source editing, and the included Interix SDK tools for compiling, linking, and debugging ( gcc and gdb) .
The development environment comprises all of the hardware and software that enables migration from UNIX to the Microsoft
Software development kits (SDKs), which include compilers, editors, and
Integrated development environments (
Software management tools, such as software for source code managementand problem tracking, are not critical, but they add significant value to larger migration projects.
Analysis tools, such as performance analysis and testing tools, can be used to improve the performance of the application.
Cross-platform tools and libraries, including third-party packages such as Rogue Wave SourcePro, can be integrated with the application.
These facilities are appropriate to either the developers or the testers of the system, as shown in Figure 7.1.
Figure 7.1: The development environment
Visual Studio is a comprehensive and powerful tool for developers. It includes features such as interactive IntelliSense for editing source, edit and continue debugging, integration with Visual SourceSafe for source control, and an
The best way to
An SDK contains tools to help build, debug, test, and deliver applications. It also contains all the definitions (include files) and libraries needed to compile programs. In general, SDK tools are run from the command line, just as applications are run from a shell prompt in UNIX. Output from SDK tools can be files created on the disk, text output to the console (like
The Microsoft Platform SDK is a set of tools and API definitions to help create applications for the Windows platform. It contains include files and documentation
The Platform SDK is available on CD or as a free download on the Web. It is also available with the Microsoft Visual C++ development system and Visual Studio,or with an MSDN Professional or Universal subscription. To order or download the SDK, go to http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ .
The Windows Platform SDK contains tools in several categories to help build applications, including:
Cryptography, to create and manage certificates.
Microsoft DirectX application programming interface. to manage three-dimensional models, graphs, and DirectX devices.
Messaging API (MAPI), for message, address book, and other
The Multimedia for AVI editor.
OLE DB for OLE object and file viewers and the MIDL compiler.
Resource files for image editor and resource compiler.
Telephony API (TAPI), for TAPI browsers.
Text Files tools, for identifying file differences.
Windows Sockets, for service provider ordering.
Most migration projects rely heavily on the Text Files tools.
, for example,is a graphical tool for comparing files and directories, recursively if desired. Files with differences can be
The symbolic debuggers in the Platform SDK can set breakpoints, execute the program or step through it one line at a time, and examine memory and registers. The debuggers understand the debugging information in the application, and can display the source with the executing program.
The symbolic debuggers are:
NTSD for debugging user mode programs.
KD for kernel debugging.
WinDBG for debugging Windows-based programs, services, and kernel-mode drivers.
The Platform SDK also contains Spy and Viewer programs that debug Windows objects:
The Spy program (Spy.exe) helps to monitor messages sent to one or morewindows and to examine the values of message parameters.
The Object Viewer (Winobj.exe) examines all of the objects in the running system, such as kernel objects and file systems, as well as user-viewable properties of objects.
Some tools that help improve the performance of applications are included with both the Platform SDK and Visual Studio. This section discusses only these Platform SDK command-line tools:
Call Attributed Profiler (CAP)
Performance meter (Perfmtr)
Working Set Tuner (WST)
(For information about Windows-based tools included with both the SDK and Visual Studio, see Performance Tuning later in this chapter.)
Call Attributed Profiler (CAP), a normal function call profiler, runs from the command line. CAP is similar to the UNIX prof profiler. CAP can show how much time is spent in each function and in other functions it calls.
To control the granularity of profiling, you specify which DLLs and functions to include. CAP produces a call tree of all the functions called in the module being profiled, together with the time spent in each.
CAP supports the following measurement techniques:
Measuring calls from an executable file (.exe)
Measuring calls from a DLL
Measuring calls from an .exe file to all of its DLLs
Measuring calls from a DLL to all of its DLLs
Any combination of the above
The Perfmtr (performance meter) command-line utility dynamically displays system performance information. The information is updated every two to three seconds. Perfmtr starts by displaying CPU usage data. However, single-letter keyboard commands prompt it to display performance information such as those shown in Table 7.1.
Virtual memory usage
X86 VDM statistics
File cache usage
Cache Manager read and write operations
Repeats the current information type
Quits the utility
Pstat displays process statistics as text. Command-line options instruct Pstat to display all statistics for all processes, for user-mode processes, or for kernel-mode processes. (If Pstat gets statistics for all processes, output will be at least several hundred lines.)
VADump examines the virtual address of a running process. Depending on the options specified, the output of VADump can include:
Each address, along with its size, state, protection, and type.
Total committed memory for the executable file.
Total committed memory for each DLL.
Total mapped committed memory.
Total private committed memory.
Total reserved memory.
Information about the working set.
Information about paged and nonpaged pool usage.
Because VADump can generate a very large amount of output, it is advisable to redirect the output to a file.
The Working Set Tuner (WST)
The working set of a program consists of those pages from the virtual address space that are mapped into active physical memory for the process. It includes both private data and shared data (program code including executable files, DLLs, and system DLLs.)
Unlike the SDK command-line tools, integrated development environments offer the user an integrated set of tools such as editors, compilers, and debuggers. Microsoft Visual Studio, the IDE discussed here, comes with a choice of languages such as C/C++ and Visual Basic, compilers and debuggers, and a large set of integrated tools that do everything from create resources to package applications for installation.
This chapter uses Visual Studio 6.0 as the basis for features and examples. The newest version of Visual Studio is Visual Studio .NET. This version includes the new features of the Microsoft .NET Framework and the common language runtime. Visual Studio .NET is covered in greater detail in Chapter 15, Roadmap for Future Migrations.
This section discusses the Visual Studio features that provide compiling and linking, debugging, and performance tuning. It also includes a section that discusses third-party extensions to Visual Studio.
Visual Studio provides a state-of-the-art C/C++ optimizing compiler and preprocessor. Users can specify options to the compiler by using the GUI dialog boxes, or from the command line when using an external make procedure. As in UNIX, link options to the compiler are passed on to the linker.
Options to the compiler can include:
Code generation options identify capabilities, such as structured exceptionhandling (SEH) model and processor.
Output Files options identify
Debugging options set preferences for debugging information output.
Preprocessor options set, for example, location of files and defined constants.
Language options enable or disable language extensions.
Linking options include DLL output, threading model, and others.
Precompiled header options set compilation speed.
Miscellaneous options include Help, compile without linking, and others.
Each built-in Visual Studio debugger for C/C++ and Visual Basic has its own window in the Visual Studio IDE. Many of these windows can be
Visual Studio includes tools for analyzing the performance of applications, including:
The PView process viewer uses dialog boxes to view and modify running processes and their threads.
PView can monitor:
Memory usage of a process, of threads, and of individual DLLs.
CPU time used by processes and threads.
How an application or the system runs with different system priorities.
PView features provide powerful tools with which developers can monitor an application s processes and threads at different priorities. Changing priorities may also affect other applications running on the same system. Developers need to take this into account when using PView.
Profiler helps to analyze program execution either at the function level or at the level of individual lines of source code. Profiler can help determine which partsof code take a long time to execute and which
Profiler can be used:
To count how many times a function is called. If the test data shows that a function is called too many or too few times, the application code could be in error.
To determine the amount of time used by a function. If a function takes too long to execute, inefficient algorithms could be to blame.
To determine coverage of testing procedures by verifying that all functionsare called or that they are called the correct number of times.
Spy++ (Spyxx.exe) shows a graphical view of the system s processes, threads, windows, and window messages. Spy++ has a toolbar,
Third-party tools that integrate with Microsoft Visual Studio to enable detectionof run-time errors include BoundsChecker from Compuware and PurifyPlus from Rational Software.
BoundsChecker, a run-time error detection tool, was originally a single product.It is now part of the DevPartner Studio suite, which contains performance as wellas debugging tools.
BoundsChecker can diagnose programming problems unique to C++, such as stack and heap memory errors and leaks of memory and resources. BoundsChecker also eliminates common Windows mismatched argument problems by checking APIcalls for Win32, ODBC, and Internet, among others.
PurifyPlus contains the Purify error and memory problem detection tool in addition to performance tools to analyze bottlenecks and to detect untested code. PurifyPlus also checks for errors in API calls, including Win32, ActiveX controls, COM objects, and DLLs. PurifyPlus detects C++ memory problems such as heap and stack errors, pointer errors, memory usage errors, and handle errors. PurifyPlus also works outside the Visual Studio IDE for stand-alone debugging.
MKS Software offers an extension to Visual Studio 6.0 to support the UNIX lex and yacc utilities. The lex utility is a scanning utility that analyzes input text files forthe occurrence of predefined text patterns. When the text pattern is found, a set ofC source code is run. The lex utility reads its input from a specified input file, or from standard in. The input is in the form of pairs, with the text expression to scan for first, followed by the C code to execute when the text expression is found. The lex utility produces a C source file that is compiled to create the scanning program.
The yacc (yet another compiler compiler) utility is a parser that takes a setup input token and applies a set of grammar rules to the token. The yacc utility generatesa C program based on the input of grammar rules from an input file or from standard in. The C program parses an input based on the grammar rules supplied when yacc was run.
The combination of
provide developers with a powerful method for generating compilers, front-end processors for compilers, text processors, and language translators. The
utilities work as add-ins to Visual Studio 6.0 that allow developers to create
Source code management tools can be integrated into the Visual Studio IDE to perform automatic checkout when a developer modifies a file. Source code management tools that integrate with Visual Studio have point-and-click interfaces, which may be new to UNIX developers.
Visual SourceSafe, the source management tool included with the Visual Studio IDE, creates projects in a tree view structure. Visual SourceSafe provides full source control for check in, check out, and difference tracking. Visual SourceSafe uses COM Automation for customization.
The Automation model can help automate the migration of source from UNIX to Windows by automating repetitive tasks. For example, in a batch build processthe Automation features of Visual SourceSafe can be used to get the source code automatically before it is compiled.
Like other source code control systems, Visual SourceSafe maintains a library of projects from which users check out files for exclusive or nonexclusive access. After modification and testing, users check in the files. If nonexclusive checkoutis allowed, the files are merged at check-in time, interactively if necessary. Each incremental checked-in version can be recalled if functionality is inadvertently deleted. VSS can also create releases by labeling the files.
Visual SourceSafe handles text as well as binary files.
Once an application is created, the developer needs a way to effectively distribute the application to the target users. This needs to be done in a reliable and repeatable manner. The Microsoft Installer (MSI) technology provides this capability.
MSI allows the developer to generate an installation package that organizes an application s setup into a set of features that can be installed through the command line, or through Control Panel, by using the Add or Remove Programs options.In addition to installation, MSI provides uninstall functionality, automatic application repair, and installation with elevated privileges.
MSI creates installation packages through a set of programming APIs and a package installation database. A developer can work with MSI by using the API directory. However, a tool that generates MSI scripts can help automate the process. The Microsoft Platform SDK provides such a tool ” Orca.exe. Orca allows the developer to directly edit the content of the MSI database. Detailed information about Orca can be found on the Platform SDK Online Help or the Microsoft MSDN Web site at:
Third parties such as Wise Solutions and InstallShield provide products that further automate the creation of MSI installation packages. These tools have options that allow a developer to create a before snapshot of a target system. The developer can then manually install the package and take an after snapshot of the system. The difference becomes the MSI package.
For more detailed information about MSI, see the Microsoft TechNet Web site at http://www.microsoft.com/technet/default.asp . The current page with MSI contentas of creation of this guide is:
Every migration of an application from UNIX to Windows requires some inter-operability between the UNIX development environment and the Windowsdevelopment environment.
A rewrite to Win32 requires the least
Third-party cross-platform environments or libraries are popular solutions for maintaining code on multiple versions of UNIX and Windows operating systems. Because a layer of abstraction isolates the differences in the platforms in this case, users can develop applications without as much attention to operating system-specific code.
A given third-party library or toolset may not provide complete coverage for all aspects of program design. For example, one library could be designed to createan abstraction for operating system functionality such as processes and threads. Another library could address graphical user interface functionality.
For this reason, the functionality applications need is a major factor in choosing a vendor. The level of the interoperability required between the UNIX and Windows environments influences vendor choice. For more information about interoperability, see Chapter 6, UNIX and Windows Interoperability.
Interix is a multiuser UNIX environment that operates on computers running Windows. The Interix subsystem and its
This section discusses Interix APIs, Interix utilities, and Interix networking and security issues.
Interix includes a Software Development Kit (the Interix SDK) that provides a full set of APIs (more than 1900) plus header and library files for creating and migrating UNIX applications.
The Interix SDK includes documentation and header files for the following categories of APIs and services:
User interface services, including
Remote procedure calls (RPCs)
System V interprocess communication (IPC) mechanisms
Berkeley Software Distribution (BSD) string and memory functions
Setup and system administration
Tools and scripting
The Interix environment includes both the Korn and C
Table 7.2 shows some widely used development tools included with Interix.
Text editors and processors
Archives, compression, and source management tools
To create and maintain library archives:
Configuration, management, and build process tools
To translate Awk to Perl:
Compilers and linkers
Portable GNU (not UNIX) assembler:
Debuggers and debugging assistance
To run a Win32 command (such as during migration of scripts):
In addition, the Interix /usr/
This section covers some of the networking and security differences between UNIX and Interix. In particular it covers:
Network resource security
User name differences
Daemons and services
The /net virtual directory is similar to the Windows Universal Naming Convention (UNC). For example, the file referred to as \\Saturn\marketing\report.xls using Windows UNC can be referred to as /net/Saturn/marketing/report.xls using Interix.
To make resource ownership information consistent across computers, Interixuses User Name Mapping (when available) to associate Windows users with user identifiers (UIDs) and group identifiers (GIDs). If there is no User Name Mapping server available, the Interix subsystem computes a UID or GID as it encounters each Windows user or
The Interix subsystem principal domain is designed to reduce the length of the displayed user and group names. The principal domain is separate from the system s primary domain. The
for a system is the domain to which the system is joined; that is, the domain displayed in System Properties. The Interix
is set by default to the system primary domain, but this setting can be
UNIX system services are handled by server programs called daemons . Windows server-level programs are called services . Unlike a daemon, a service logs on to the computer by using a user account. This gives the Windows administrator greater control over the privileges granted to the service and, when the service logs on with a domain account, even allows the service to access network resources.
Interix can take advantage of both Windows and UNIX mechanisms to provide services such as inetd ( the UNIX super server for Internet services). By default, Interix runs such services as traditional UNIX daemons, using the init utility to start and stop these daemons. Similar to a traditional UNIX system, Interix runs init as part of its startup procedure. When it starts, init executes scripts referenced by symbolic links located in /etc/rc2.d. Then, init continues to run until it receives a termination signal, at which point it runs shutdown scripts for the daemons it started.
Rogue Wave SourcePro consists of a set of libraries that enable cross-platform compatibility of applications between UNIX and Windows. Its C++ components handle many of the intricacies of the C++ language and provide high-level object-oriented interfaces to complex underlying APIs. With minimal code changes, applications built by using SourcePro
Rogue Wave SourcePro consists of libraries for core functionality and for database and networking support.
The Rogue Wave SourcePro core library consists of five modules:
The Standard C++ Library Module is a complete implementation of the ISO/ANSI Standard for the C++ Programming Language. Sun, Hewlett-Packard, and Compaq ship Rogue Wave s implementation of the ANSI Standard C++ Library with their C++ compilers.
The Essential Tools Module offers an internationalized set of fundamental C++ components that are useful in almost any type of C++ application. They provide user interfaces to the underlying ANSI Standard C++ Library and features beyond those in the ANSI standard, including classes for handling dates and times. Developers can use this module to write a single C++ application that can ship to any country.
The Advanced Tools Module offers a mechanism for complex stream transformations and object serializations, which can stream C++ classes with minimal code changes.
The XML Streams Module builds on the Advanced Tools Module, enabling C++ data to be written to or read from an XML stream. Because instances of C++ classes can be turned into XML without writing XML streaming code, developers can integrate existing C++ code into systems that use XML to communicate.
The Threads Module provides a higher level, object-oriented API that hides many of the complexities of multithreading in C++; that is, developers are
Developers can create secure or nonsecure networked and Internet-enabled applications by using Rogue Wave SourcePro Net to handle the details of socket programming and Internet protocols. In SourcePro Net, developers can implement standard Simple Object Access Protocol (SOAP) concepts using their existing C++ knowledge and XML. Because SourcePro Net has a layered architecture, developers can choose the level of abstraction for an application, such as the abstract layer for ease of use, or the protocol layer for finer control of details.
SourcePro Net includes four modules:
The Essential Networking Module includes a high-level API for networking applications (it encapsulates the details of socket programming).
The Internet Protocols Module provides an API for developing Internet-enabled client-side applications (it encapsulates the details of key Internet protocols).
The Secure Communication Module provides an API for developing secure networked and Internet-enabled applications (it encapsulates the details of the low-level HTTPS protocol). This module also offers a high-level C++ API to Secure Socket Layer/Transport Layer Security [SSL/TLS] implementations, including RSA s commercial product BSAFE SSL-C and the
The Web Services Module encapsulates the current SOAP specifications, including SOAP 1. 2, SOAP with attachments, and XML Schema 2001. By using the Web Services Module, developers can convert SOAP objects to and from strings, enabling the objects to work with any networking or deployment technology.
Rogue Wave SourcePro DB provides relational database access in C++. The SourcePro DB object-oriented interface abstracts the complexity of writing database applications, but still allows access to the native database client libraries when needed. SourcePro DB encapsulates the ANSI SQL 92 standard and
The OpenSQL API helps to improve performance on a specific database by providing lower-level access that uses a
By using cross-platform graphical user interface (GUI) tools, developers can write applications with an API consistent with both UNIX and Windows. The cross-platform tools usually create an abstraction through which the application can use the X-Windows system on UNIX and the Windows API on the Microsoft platform.
Some cross-platform GUI tools come from an independent software vendor (ISV), and others are open source. Even some open source versions come from a vendor with a support option. Examples of these cross-platform tools are the Carnac 2D graphics toolkit from INT, Inc., and the Qt toolkit from Trolltech.
Carnac, a cross-platform interactive display system, is a C++ library availableon several UNIX systems as well as on the Windows NT and Windows 2000 operating systems.
Carnac is designed to handle applications that have high-end graphics requirements. For optimum performance, Carnac drives the native graphics pipeline of the target system.
Carnac supports the following features in
Applications written in C++
Hard copy produced by PostScript
Computer Graphics Metafile (CGM) (optional)
Web browser support (optional)
Visual properties that can be set on
View layering (data can be categorized)
Advanced scaling, rotation, selection, and shape modification
Ability to persist pictures as binary or ASCII
For more information, see the INT Web site at http://www.int.com .
The Trolltech Qt toolkit, a C++ cross-platform library available on several Windows-based and UNIX systems, provides platform-independent toolsets. Developers can use it to write applications to a single API with a single source code base. Qt is
Qt application development functionality, implemented as C++ classes, covers GUI, database, networking, and file handling. Classes and libraries used for database and file handling (and others) are separate from and are not required for using the GUI classes, where the Qt toolkit focuses its functionality.
Qt does not implement GUI by wrapping the native windowing capabilities. Instead, it creates its own abstraction layer, which means the toolkit can change look-and-feel characteristics between Windows, Motif, and other customizable schemes, depending on whether the application runs on a Windows or Motif system.
Qt also supports advanced graphics requirements that use the OpenGL extensions. Applications developed using Qt widgets can use OpenGL functionality.
For more information, see the Trolltech Web site at http://www.trolltech.com .
Another approach to creating system architecture that runs UNIX programs on Windows operating systems is to create UNIX emulation by using Win32. Such a program runs as a Win32-based application or service that accepts commands from the user through a command window. Because these systems are emulations rather than native Windows subsystems, performance of
UNIX emulation systems for Windows include the following:
Cygwin, which was developed by Cygnus Solutions and later Red Hat, featuresa port of the GNU development tools and utilities. Cygwin offers a UNIX-like development environment running on Windows. Cygwin does not implement a single, complete UNIX environment. Instead, it combines the features of several UNIX versions and Linux.
NuTCRACKER, which is part of the MKS Toolkit, features both the C and Korn shells. This makes many UNIX developers feel comfortable working with it. MKS delivers most of the UNIX 98 APIs plus features from specific UNIX versions and POSIX, such as threads. There is also a complete X-Windows system including a server.
U/WIN (UNIX for Windows), which was developed by David Korn, can be downloaded free of charge from the AT&T Research Web site for educational and research purposes. Commercial users must have a license. U/WIN uses the Korn shell. U/WIN provides support for most UNIX features including signals, UCB-style sockets, and devices.