Working in 32-bit and 64-bit Modes

This chapter describes how to use Server Express in 32-bit mode or 64-bit mode. You need only read this chapter if you have installed the 64-bit version of Server Express.

In this Chapter

Introduction

If your UNIX platform supports the execution of 64-bit applications, Server Express for that platform is installed with both a 32-bit version and 64-bit version of the Server Express development and run-time systems. This enables you to write programs that can be run on both 32-bit and 64-bit systems, and to migrate applications from 32-bit systems to 64-bit systems.

The development tools, run-time libraries and run-time system for both the 32-bit and 64-bit version of Server Express are located in the $COBDIR directory.

You can specify a working mode for Server Express; that is, whether the default development system is the 32-bit system or the 64-bit system. Whichever working mode you specify, you can always use tools that work in the other mode. For example, if you set Server Express to work in 32-bit mode by default, you can still run 64-bit versions of the tools and utilities.

Finding the Current Working Mode

The working mode can be global or local. The global working mode affects all users of the development system. The local working mode is specific to your local environment.

You can find out your working mode by using the cobmode command as follows:

cobmode

To find your current local working mode, enter the command:

cobmode -l

To find the current global working mode, enter the command:

cobmode -s 

If you want to know how your working mode is determined add the -v option to the cobmode command line. For example:

cobmode -v

To set the working mode, see the section Setting the Working Mode.

Setting the Working Mode

You can specify the working mode when you install Server Express. This is described in your Installation Notes.

You can set the working mode at any time using the:

The COBMODE Environment Variable

Use the COBMODE environment variable to set your local working mode. The value you set using COBMODE overrides the global working mode.

The format of COBMODE is:

COBMODE=version

where version can be 32 or 64.

For example, to set the local working mode to the 64-bit development mode:

COBMODE=64
export COBMODE

The cobmode Command

To set the global working mode use the cobmode command.

The format of the cobmode command used to set the global working mode is:

cobmode -s version

where version can be 32 or 64 .

For example, to set the global working mode to the 64-bit version:

cobmode -s 64

Default Working Mode

The working mode defaults to a particular mode depending on what parts of the product have been installed, and to what values the local and global working modes have been set.

The working mode is determined using the following rules, listed in order, most significant first:

Starting the Required Tool

Both 32-bit and 64-bit versions of the tools and utilities are provided. They are suffixed with either 32 or 64 as appropriate. The tools and utilities are also provided in unnumbered versions. You do not need to alter $PATH, $COBDIR, and $LD_LIBRARY_PATH, $LIBPATH or $SHLIB_PATH in order to switch between working modes.

For example:

cob32 -i myprog.cbl
cobrun32 myprog

compiles the program myprog.cbl to the 32-bit intermediate code file myprog.int, and then runs it.

cob64 -i myprog.cbl
cobrun64 myprog

compiles the program myprog.cbl to the 64-bit intermediate code file myprog.int, and then runs it.

For development tools (such as the Cob utility), the unnumbered versions always obey the current working mode. See the section Default Working Mode.

For cobrun and Animator, the unnumbered versions locate the application named on the command line and automatically run it in the correct mode. If the named application cannot be located, these tools obey the current working mode.

For example:

cobrun64 myapp.int 

runs myapp.int in 64-bit mode. If myapp.int is a 32-bit application then a run-time error occurs.

cobrun myapp.int 

runs myapp.int in either 32-bit or 64-bit mode, as appropriate, depending on which mode myapp.int was compiled to.

anim myapp

runs Animator, using myapp, in either 32-bit or 64-bit mode, as appropriate, depending on which mode myapp.int was compiled to.

These examples are true for .int files, .gnt files and callable shared objects. However, system executable files are run in the same way for both 32-bit and 64-bit modes. For example, you can create and run 32-bit and 64-bit system executable files from the program myprog.cbl as follows:

cob32 -x myprog.cbl
./myprog
cob64 -x myprog.cbl
./myprog 

Determining the Format of an Executable File

Both operating system executable files and Micro Focus executable files are held in different formats depending on whether they are 32-bit or 64-bit files. You can use the same commands to run and debug 32-bit and 64-bit executable files, since the commands can identify which format they are dealing with. However, there might be times when you need to find out what format an executable file is in.

Operating System Executable Files

To determine the format of an operating system executable file, such as an object file (.o file) or a shared object file (.so file), use the UNIX file command. For example:

file myobj.o

displays one of the following on a Solaris SPARC machine

myobj.o:   ELF 32-bit MSB relocatable SPARC version 1
myobj.o:   ELF 62-bit MSB relocatable SPARCV9 version 1

Micro Focus Executable Files

To determine the format of a Micro Focus executable file, use the Server Express cobfile command. This command checks for intermediate code files (.int files), generated code files (.gnt files) Animator information files (.idy files), and library files (.lbr files) produced on Server Express (32-bit and 64-bit) and OCDS Version 4.1 and later. It also checks for screen output recording files (.scn files, where n is a hexadeximal digit between 1 and F) and keystroke files (.key files).

The cobfile command takes the following format:

cobfile file [file] ...

where file is the filename of a Micro Focus executable file.

For example:

cobfile myprog.int

displays one of the following:

myprog.int: Micro Focus 32-bit intermediate code file
myprog.int: Micro Focus 64-bit intermediate code file

If you supply more than one file parameter to the cobfile command, the command displays a list of results in the same order as the parameters, with one line per file.

If the cobfile command does not recognise a a filename supplied in a file parameter as a Micro Focus format file it passes the parameter to the UNIX file command.

Shipping Dual-mode Applications

If you ship an application that contains both 32-bit and 64-bit versions of your programs, you can either:

Configuration Files

You can configure various utilities, and the run-time system, using configuration files.

Configuration files that effect the run-time system, such as cobconfig, have no suffix whatever version of Server Express you are using. In this case, the settings are shared between the 32-bit and 64-bit versions.