Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Example 2: Compiling, linking, and starting a C++ program

&pagelevel(4)&pagelevel

The C++ source program consists of two PLAM library elements PROG1 and PROG2. The compiler generates LLMs and writes them to the PLAM library SYS.PROG.LIB. These modules are then linked with the BIND statement of the compiler.

Source program element PROG1

#include <iostream.h>
extern void invoke(void);
int main(void)
{
   cout << "main(prog1)" << '\n';
   invoke();
   return 0;
}

Source program element PROG2

#include <iostream.h>
void invoke(void)
{
   cout << "invoke(prog2)" << '\n';
}

The source program extracts shown above were produced using EDT and then written separately to the PLAM library PLAM.EXP with explicit WRITE statements of the form:WRITE L=PLAM.EXP(E=element-name)

Runtime listing for compilation, linkage and execution

(IN)   indicates user inputs
(OUT)  indicates system program messages
(IN)   /START-CPLUS-COMPILER ——————————————————————————————————————————  (1) 
(OUT)  %  BLS0523 ELEMENT ’SDFCC’, VERSION ’04.0B02’, TYPE ’L’ FROM LIBRARY
         ’:P401:$TSOS.SYSLNK.CPP.040’ IN PROCESS
(OUT)  %  BLS0524 LLM ’SDFCC’, VERSION ’04.0B02’ OF ’2023-04-02 13:40:11’ 
          LOADED
(OUT)  %  BLS0551 COPYRIGHT (C) 2023 Fujitsu Technology Solutions GmbH. ALL
          RIGHTS RESERVED
(OUT)  %  CDR9992 : BEGIN C/C++ VERSION 04.0B02
(IN)   //MOD-SOURCE-PROP LANGUAGE=*CPLUS(V3-COMPATIBLE) ———————————————  (2)
(IN)   //MOD-BIND-PROP RUNTIME-LANGUAGE=*CPLUS(*V3-COMPATIBLE) ————————  (2)
(IN)   //COMPILE SOURCE=(*LIB(LIB=PLAM.EXP,ELEM=PROG1),-
       //*LIB(LIB=PLAM.EXP,ELEM=PROG2)) ———————————————————————————————  (3) 
(OUT)  %  CDR9907 : NOTES: 0  WARNINGS: 0  ERRORS: 0  FATALS: 0
(OUT)  %  CDR9937 : MODULES GENERATED, CPU TIME USED = 0.0030 SEC
(OUT)  %  CDR9907 : NOTES: 0  WARNINGS: 0  ERRORS: 0  FATALS: 0
(OUT)  %  CDR9937 : MODULES GENERATED, CPU TIME USED = 0.0020 SEC
(IN)   //MOD-BIND-PROP INCLUDE=(*LIB(LIB=SYS.PROG.LIB,ELEM=PROG1),-
       //*LIB(LIB=SYS.PROG.LIB,ELEM=PROG2)) ———————————————————————————  (4) 
(IN)   //BIND OUTPUT=*LIB(LIB=PLAM.EXP1,ELEM=PROG) ————————————————————  (5) 
(OUT)  %  BND1501 LLM FORMAT: ’4’
(OUT)  %  BND3102 SOME WEAK EXTERNS UNRESOLVED
(OUT)  %  BND1101 BINDER NORMALLY TERMINATED. SEVERITY CLASS: 
          'UNRESOLVED EXTERNAL'
(IN)   //END ——————————————————————————————————————————————————————————  (6) 
(OUT)  %  CDR9936 END; SUMMARY: NOTES: 0  WARNINGS: 0  ERRORS: 0  FATALS: 0
(OUT)  %  CCM0998 CPU TIME USED: 1.9967 SECONDS
(IN)   /START-EXECUTABLE-PROG*L(LIB=PLAM.EXP1,E-O-S=PROG) —————————————  (7) 
(OUT)  %  BLS0523 ELEMENT 'PROG', VERSION '@', TYPE 'L' FROM LIBRARY
          ':2OS2:$USERIDXY.PLAM.EXP1' IN PROCESS
(OUT)  %  BLS0524 LLM '$LIB-ELEM$PLAM$EXP1$$PROG$$$UPPE', VERSION ' '
          OF '2020-04-02 14:22:01' LOADED
(OUT)  main(prog1)
(OUT)  invoke(prog2)
(OUT)  %  CCM0998 CPU TIME USED: 0.0018 SECONDS

(1)

The compiler run is started.

(2)

The language mode is set for compiling and linking.

(3)

The COMPILE statement is issued to start compiling the C++ source program elements PROG1 and PROG2. The name off the PLAM library and that of the library element to be compiled are specified individually in the SOURCE option in the form of a list. By default, the compiler places the generated LLMs in the library SYS.PROG.LIB. The names of the LLMs are derived from the names of the source program elements (PROG1, PROG2).

(4)

The MODIFY-BIND-PROPERTIES statement specifies which modules are to be linked in the following linkage run. The INCLUDE option (which corresponds to the BINDER statement INCLUDE-MODULES) specifies the names of the LLMs to be linked, i.e. the LLM containing the main function (PROG1) and the additional LLM with the subroutine (PROG2). All other C and C++ runtime library modules required for C++ V3 programs are linked in automatically (with the autolink mechanism, see "MODIFY-BIND-PROPERTIES").

(5)

The linkage run is started with BIND statement. The OUTPUT option (which corresponds to the BINDER statement SAVE-LLM) causes the generated LLM to be saved under the name PROG as an element of type L in a PLAM library.The BINDER message “SOME WEAK EXTERNS UNRESOLVED” refers to the ILCS module IT0INITS. This module contains WEAK-EXTERN references to all potential languages for ILCS. Only the C and C++ languages are involved in this example, so the other references remain unresolved. For more information on the LLM format generated by BINDER (Format 4 in this example), please refer to the OUTPUT-FORMAT option of the BIND statement ("BIND").

(6)

The compiler run is terminated with the END statement.

(7)

The fully-linked program is loaded and started with the START-EXECUTABLE-PROGRAM command.