Highlighted
Absent Member.
Absent Member.
1229 views

[archive] How to create a subroutine library

[Migrated content. Thread originally posted on 19 March 2010]

Michael,

I seem to remember from my time at Acu that multiple programs in a single source file were always a problem. I think a tool got created that split them out into single source files, but I can't remember the details, sorry.

Nigel
0 Likes
7 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] How to create a subroutine library

I've done this using other COBOL compilers, that is, create a .lib or .DLL or .so file that contains multiple subroutines to be called by an application.

I have one COBOL source file that contains hundreds of of programs, ea:

INDENTIFICATION DIVISION
ENVIRONMENT DIVISION
DATA DIVISION
PROCEDURE DIVISION
code..
code...
END PROGRAM
**************
INDENTIFICATION DIVISION
ENVIRONMENT DIVISION
DATA DIVISION
PROCEDURE DIVISION
code..
code...
END PROGRAM
**************
INDENTIFICATION DIVISION
ENVIRONMENT DIVISION
DATA DIVISION
PROCEDURE DIVISION
code..
code...
END PROGRAM
**************


The example above is Hypothetical, the actual code is pushing 10,000 lines of cobol and hundreds of programs, I really don't want to break it up into separate source files.

When I try to compile it into an ACU file using
"ccbl32 -Sp S:\copylib -o s:\vplus\sp2vplus32.acu -v -La -Dw64 -Cp -o S:\vplus\@.acu -x -Ga sp2vplus32.cbl"
it only compiles the first program, it seems to stop at the first "END PROGRAM".
their must be a way to get AcuCobol to compile all programs in the file, and place the resulting object code into one acu file, or a .DLL, .LIB, or .so

Any help will be much appreciated!
Michael. :confused:
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] How to create a subroutine library

To make the question simpler, I have the same problem using this compile command:

ccbl32 -v -La sp2vplus32.cbl

NOTE: THE 125 LINES BELOW! That's where the first END PROGRAM is found.

STATISTICS

Total Lines: 125
# of Files: 0
# of Data Items: 21
# of Paragraphs: 9

Elapsed Time: 0.0 seconds
Lines/Minute: 187500


Code Size: 607 (00025F)
Data Size: 138 (00008A)
Shared Data: 56 (000038)
Extra Segment: 42 (00002A)
Thread Segment: 36 (000024)
Address Table: 360 (000168)
Program Size: 1239 (0004D7)

0 Error(s), 0 Warning(s), 0 Caution(s)
Compilation complete
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] How to create a subroutine library

Now once they are all compiled, how can I put them into one library file?

There is a utility (cobutil32?) that does this, at least I think it does. But it can't be tested because when all routines are combined into one file.acu using the utility I can't seem to make calls to any of the routines. The error is NOT A COBOL PROGRAM.

I guess the best way to do all of this with AcuCobol is to re-write using Entry Points. 😞

Any other options?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] How to create a subroutine library

Yes, you can do this. First, you must split the source into separate files. Acu doesn't support multiple programs in a single source file (entry points, yes, but not separate programs).

Then combine the objects into a library with cblutl32 (on Windows) or cblutil (on Unix/Linux):

[INDENT]cblutl32 -lib -o mylib.lib prog1.acu prog2.acu prog3.acu[/INDENT]


Then preload the library with the -y runtime option (it only preloads the addresses of the programs within the library, not all of the code):

[INDENT]wrun32 -y mylib.lib prog1[/INDENT]


and within prog1 you can call the others. On a call, the preloaded object library will be searched first, then if not found the runtime will search for a .acu file on disk.

Note that once you've preloaded the library, you refer to the contained programs by their PROGRAM-ID's, not the physical .acu filenames. It's a good practice to always make them the same, though 🙂

And, finally, the Acu compiler doesn't compile to .dll, .so, or .exe formats. Never has, never will...
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] How to create a subroutine library

Michael,

I seem to remember from my time at Acu that multiple programs in a single source file were always a problem. I think a tool got created that split them out into single source files, but I can't remember the details, sorry.

Nigel

Nigel, you're probably thinking of "libutil", which is a utility designed to run on an MPE (hp3000) system to split KSAM copylibs into separate files for use on other systems that don't support KSAM. But as far as I know, we never built anything to deal with the multiple programs in a single file.

Chuck
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] How to create a subroutine library



... try to compile it into an ACU file using
"ccbl32 -Sp S:\copylib -o s:\vplus\sp2vplus32.acu -v -La -Dw64 -Cp -o S:\vplus\@.acu -x -Ga sp2vplus32.cbl"



Michael, I notice in your compile command that you have the -o option repeated. Only the LAST one will be used, although in this case they both resolve to the same filename.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] How to create a subroutine library

Nigel, you're probably thinking of "libutil", which is a utility designed to run on an MPE (hp3000) system to split KSAM copylibs into separate files for use on other systems that don't support KSAM. But as far as I know, we never built anything to deal with the multiple programs in a single file.

Chuck


Hi Chuck, I think it was one of those "gotta finish this one day" projects that never got high enough on the radar. I probably have a completely unfinished prototype lying around somewhere... 😉
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.