Reputation: 339
I've installed GnuCOBOL 2.2 on my Ubuntu 17.04 system. I've written a basic hello world program to test the compiler.
1 IDENTIFICATION DIVISION.
2 PROGRAM-ID. HELLO-WORLD.
3 *---------------------------
4 DATA DIVISION.
5 *---------------------------
6 PROCEDURE DIVISION.
7 DISPLAY 'Hello, world!'.
8 STOP RUN.
This program is entitled HelloWorld.cbl. When I compile the program with the command
cobc HelloWorld.cbl
HelloWorld.so is produced. When I attempt to run the compiled program using
cobcrun HelloWorld
I receive the following error:
libcob: entry point 'HelloWorld' not found
Can anyone explain to me what an entry point is in GnuCOBOL, and perhaps suggest a way to fix the problem and successfully execute this COBOL program?
Upvotes: 4
Views: 2265
Reputation: 1289
According to the official manual of GNUCOBOL, you should compile your code with:
cobc -x HelloWorld.cbl
then run it with
./HelloWorld
You can also read GNUCOBOL wiki page which contains some exmaples for further information.
P.S. As Simon Sobisch said, If you change your file name to HELLO-WORLD.cbl
to match the program ID, the same commands that you have used will be ok:
cobc HELLO-WORLD.cbl
cobcrun HELLO-WORLD
Upvotes: 5
Reputation: 7287
Can anyone explain to me what an entry point is in GnuCOBOL, and perhaps suggest a way to fix the problem and successfully execute this COBOL program?
An entry point is a point where you may enter a shared object (this is actually more C then COBOL).
GnuCOBOL generates entry points for each PROGRAM-ID
, FUNCTION-ID
and ENTRY
. Therefore your entry point is HELLO-WORLD
(which likely gets a conversion as -
is no valid identifier in ANSI C - you won't have to think about this when CALL
ing a program as the conversion will be done internal).
Using cobcrun
internally does:
HelloWord
), as this is found (because you've generated it) it will be loadedThere are three possible options to get this working:
cobc -x
, the reason that this works is because you don't generate a shared object at all but a C main which is called directly (= the entry point doesn't apply at all)PROGRAM-ID
(entry point), either manually with COB_PRE_LOAD=HelloWorld cobcrun HELLO-WORLD
or through cobcrun (option available since GnuCOBOL 2.x) cobcrun -M HelloWorld HELLO-WORLD
PROGRAM-ID
to match the source name (either rename or change the source, I'd do the second: PROGRAM-ID. HelloWorld.
)Upvotes: 4