Previous Topic Next topic Print topic


Simple Default Linking

You can create a system executable application file by specifying the -x flag to the cob command, together with a list of the application files that you want included in the system executable file. The application files can include COBOL, C or C++ source files, .int files or any type of .o object files. The name of the system executable file is the basename of the first application file in the list unless you specify another name by using the -o flag.

For example, the following command, compiles the program myprog.cbl to native object code and links it with the run-time support routines to produce a system executable myprog. The program can then be run by entering the name of the system executable at the command line.

cob -x myprog.cbl

If the current directory is not set in your PATH environment variable, you can run the program with a command:

./myprog

If your application contains several programs, then all the programs can be linked together. For example, the following command converts myprog.cbl and mysub.int to native object code, compiles the C source file csub.c to an object file, links them together with the COBOL run-time support routines and creates a system executable file myapp. The -v flag causes cob to give informational messages on its progress.

cob -xv myprog.cbl mysub.int csub.c -o myapp

If your application contains code written in C++ then the -x,CC cob flag should be used so that the C++ compiler (and not the system linker) creates the final system executable. For example, the following command creates the system executable myapp using the COBOL programs myprog.cbl and mysub.int, the C source file csub.c and the C++ source file cppsub.c.

cob -x,CC myprog.cbl mysub.int csub.c cppsub.C -o myapp

The default initial entry point of a system executable application file is the basename of the first program name on the command line, such as myprog in the previous example. If your application requires a different initial entry point, use the cob -e flag. For example, the following command specifies myentry as the initial entry point.

cob -xo myapp myprog.cbl subprog.o -e myentry
Previous Topic Next topic Print topic