Hi,
I have the next program:
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat main.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN.
WORKING-STORAGE SECTION.
01 STR-GOODBYE-WORLD.
05 FILLER PIC X(32) VALUE 'GOODBYE-WORLD'.
PROCEDURE DIVISION.
DISPLAY 'Entrada al programa principal...'.
CALL "HELLO-WORLD".
CALL STR-GOODBYE-WORLD.
STOP RUN.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat helloworld.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello world!'.
EXIT PROGRAM.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat goodbyeworld.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. GOODBYE-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Goodbye world!'.
EXIT PROGRAM.
I create a static library with helloworld.o and goodbyeworld.o objects.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>ar -tvf libregards.a
rw-rw-r-- 176/110 2156 Aug 1 08:38 2022 helloworld.o
rw-rw-r-- 176/110 2184 Aug 1 08:39 2022 goodbyeworld.o
I link the executable regards linking main object and static library libregards.a:
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat build_regards_exec_linking_static_library.sh
# Set COBMODE to 64 for 64bit. Defaults to 32bit.
MODE=${COBMODE:-32}
cob$MODE -v -xU -o regards main.o -L . -lregards
If a run regards program fail with error
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>regards
Entrada al programa principal...
Hello world!
Load error : file 'GOODBYE-WORLD'
error code: 173, pc=0, call=1, seg=0
173 Called program file not found in drive/directory
How do I have to link the program so that it includes all the objects contained in the static library even the ones not implicitly referenced?
Thanks.
Regards.
Hi,
I have the next program:
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat main.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN.
WORKING-STORAGE SECTION.
01 STR-GOODBYE-WORLD.
05 FILLER PIC X(32) VALUE 'GOODBYE-WORLD'.
PROCEDURE DIVISION.
DISPLAY 'Entrada al programa principal...'.
CALL "HELLO-WORLD".
CALL STR-GOODBYE-WORLD.
STOP RUN.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat helloworld.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello world!'.
EXIT PROGRAM.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat goodbyeworld.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. GOODBYE-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Goodbye world!'.
EXIT PROGRAM.
I create a static library with helloworld.o and goodbyeworld.o objects.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>ar -tvf libregards.a
rw-rw-r-- 176/110 2156 Aug 1 08:38 2022 helloworld.o
rw-rw-r-- 176/110 2184 Aug 1 08:39 2022 goodbyeworld.o
I link the executable regards linking main object and static library libregards.a:
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat build_regards_exec_linking_static_library.sh
# Set COBMODE to 64 for 64bit. Defaults to 32bit.
MODE=${COBMODE:-32}
cob$MODE -v -xU -o regards main.o -L . -lregards
If a run regards program fail with error
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>regards
Entrada al programa principal...
Hello world!
Load error : file 'GOODBYE-WORLD'
error code: 173, pc=0, call=1, seg=0
173 Called program file not found in drive/directory
How do I have to link the program so that it includes all the objects contained in the static library even the ones not implicitly referenced?
Thanks.
Regards.
The product is Visual Cobol v7.0.0 Patch Update 08_303630:
int-cob-d-01u:/opt/microfocus/VisualCOBOL/etc>cat cobver
cobol v7.0.0
PRN=KXCRH/AAD:Ao.U4.13.04
PTI=32/64 bit
PTI=Micro Focus Visual COBOL for Eclipse 7.0
PTI=pkg_281858
PTI=RPM
PTI=Micro Focus Visual COBOL for Eclipse 7.0 - Patch Update 05
PTI=Patch Update 05
PTI=pkg_290480
PTI=Micro Focus Visual COBOL for Eclipse 7.0 - Patch Update 08
PTI=Patch Update 08
PTI=pkg_303630
The product is Visual Cobol v7.0.0 Patch Update 08_303630:
int-cob-d-01u:/opt/microfocus/VisualCOBOL/etc>cat cobver
cobol v7.0.0
PRN=KXCRH/AAD:Ao.U4.13.04
PTI=32/64 bit
PTI=Micro Focus Visual COBOL for Eclipse 7.0
PTI=pkg_281858
PTI=RPM
PTI=Micro Focus Visual COBOL for Eclipse 7.0 - Patch Update 05
PTI=Patch Update 05
PTI=pkg_290480
PTI=Micro Focus Visual COBOL for Eclipse 7.0 - Patch Update 08
PTI=Patch Update 08
PTI=pkg_303630
Hello @Miguel angel Tortosa pelegrina,
The Micro Focus recommended method for building COBOL subroutines into a library file on Unix/Linux platforms, so that they can be loaded and accessed at runtime, is to use callable shared objects.
In this approach, the COBOL subprograms are linked together into a .so file. The .so file is a shared object, similar to a ".DLL" on Windows. The COBOL runtime system can dynamically load objects of this type at runtime to bring extra modules into a running executable.
A callable shared object can be created with a "cob" command similar to:
cob -z -g -o regards.so -e "" helloworld.cbl goodbyeworld.cbl
The -z tells "cob" to create a callable shared object. The -o option names the resulting callable shared object "regards.so", with a .so extension (on HP/UX, callable shared objects instead carry a ".sl" extension).
Then, the main COBOL program can be compiled (and linked) with a special INITCALL compiler directive to cause the regards.so to be automatically loaded, so that the required subroutines will be available (avoiding a 173 error) when they are called.
cob -C "initcall=regards.so" "-v -xU -o regards main.cbl
For additional background information about creating shared objects on Unix/Linux platforms, please see the following Micro Focus Community article:
Please let me know if you have any questions about the information above.
Hi,
I have the next program:
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat main.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN.
WORKING-STORAGE SECTION.
01 STR-GOODBYE-WORLD.
05 FILLER PIC X(32) VALUE 'GOODBYE-WORLD'.
PROCEDURE DIVISION.
DISPLAY 'Entrada al programa principal...'.
CALL "HELLO-WORLD".
CALL STR-GOODBYE-WORLD.
STOP RUN.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat helloworld.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello world!'.
EXIT PROGRAM.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat goodbyeworld.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. GOODBYE-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Goodbye world!'.
EXIT PROGRAM.
I create a static library with helloworld.o and goodbyeworld.o objects.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>ar -tvf libregards.a
rw-rw-r-- 176/110 2156 Aug 1 08:38 2022 helloworld.o
rw-rw-r-- 176/110 2184 Aug 1 08:39 2022 goodbyeworld.o
I link the executable regards linking main object and static library libregards.a:
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat build_regards_exec_linking_static_library.sh
# Set COBMODE to 64 for 64bit. Defaults to 32bit.
MODE=${COBMODE:-32}
cob$MODE -v -xU -o regards main.o -L . -lregards
If a run regards program fail with error
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>regards
Entrada al programa principal...
Hello world!
Load error : file 'GOODBYE-WORLD'
error code: 173, pc=0, call=1, seg=0
173 Called program file not found in drive/directory
How do I have to link the program so that it includes all the objects contained in the static library even the ones not implicitly referenced?
Thanks.
Regards.
Error 173 is not found .exe or .dll. I see your
"int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat goodbyeworld.cbl"
probably the dll/exe will be goodbyeworld.exe and you are CALLing "HELLO-WORLD". I believe this is the reason for error 173.
Translated by Google translator


Hi,
I have the next program:
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat main.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN.
WORKING-STORAGE SECTION.
01 STR-GOODBYE-WORLD.
05 FILLER PIC X(32) VALUE 'GOODBYE-WORLD'.
PROCEDURE DIVISION.
DISPLAY 'Entrada al programa principal...'.
CALL "HELLO-WORLD".
CALL STR-GOODBYE-WORLD.
STOP RUN.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat helloworld.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello world!'.
EXIT PROGRAM.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat goodbyeworld.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. GOODBYE-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Goodbye world!'.
EXIT PROGRAM.
I create a static library with helloworld.o and goodbyeworld.o objects.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>ar -tvf libregards.a
rw-rw-r-- 176/110 2156 Aug 1 08:38 2022 helloworld.o
rw-rw-r-- 176/110 2184 Aug 1 08:39 2022 goodbyeworld.o
I link the executable regards linking main object and static library libregards.a:
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat build_regards_exec_linking_static_library.sh
# Set COBMODE to 64 for 64bit. Defaults to 32bit.
MODE=${COBMODE:-32}
cob$MODE -v -xU -o regards main.o -L . -lregards
If a run regards program fail with error
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>regards
Entrada al programa principal...
Hello world!
Load error : file 'GOODBYE-WORLD'
error code: 173, pc=0, call=1, seg=0
173 Called program file not found in drive/directory
How do I have to link the program so that it includes all the objects contained in the static library even the ones not implicitly referenced?
Thanks.
Regards.
This can't work!
you must use this commands:
CALL "HELLO-WORLD".
CALL "GOODBYE-WORLD".
or
CALL "HELLO-WORLD".
PERFORM STR-GOODBYE-WORLD.
STR-GOODBYE-WORLD SECTION.
CALL "GOODBYE-WORLD".
When use "CALL" its better to use "CANCEL" to remove the program from memory!
This can't work!
you must use this commands:
CALL "HELLO-WORLD".
CALL "GOODBYE-WORLD".
or
CALL "HELLO-WORLD".
PERFORM STR-GOODBYE-WORLD.
STR-GOODBYE-WORLD SECTION.
CALL "GOODBYE-WORLD".
When use "CALL" its better to use "CANCEL" to remove the program from memory!
Your statement is only true if the configuration default_cancel_mode is changed and "GOODBYE-WORLD" is a DLL, so, int or gnt (not .obj or .o).
Otherwise, GOODBYE-WORLD is logically CANCEL'ed.
If deterministic storage is a requirement, then consider avoiding CANCEL and look at "is initial" phrase on the program-id of GOODBYE-WORLD program.
Lastly, the use of CANCEL is problematic in threaded or hosted threaded environment, so take care with its use.
Hi,
I have the next program:
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat main.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN.
WORKING-STORAGE SECTION.
01 STR-GOODBYE-WORLD.
05 FILLER PIC X(32) VALUE 'GOODBYE-WORLD'.
PROCEDURE DIVISION.
DISPLAY 'Entrada al programa principal...'.
CALL "HELLO-WORLD".
CALL STR-GOODBYE-WORLD.
STOP RUN.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat helloworld.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello world!'.
EXIT PROGRAM.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat goodbyeworld.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. GOODBYE-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Goodbye world!'.
EXIT PROGRAM.
I create a static library with helloworld.o and goodbyeworld.o objects.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>ar -tvf libregards.a
rw-rw-r-- 176/110 2156 Aug 1 08:38 2022 helloworld.o
rw-rw-r-- 176/110 2184 Aug 1 08:39 2022 goodbyeworld.o
I link the executable regards linking main object and static library libregards.a:
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>cat build_regards_exec_linking_static_library.sh
# Set COBMODE to 64 for 64bit. Defaults to 32bit.
MODE=${COBMODE:-32}
cob$MODE -v -xU -o regards main.o -L . -lregards
If a run regards program fail with error
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>regards
Entrada al programa principal...
Hello world!
Load error : file 'GOODBYE-WORLD'
error code: 173, pc=0, call=1, seg=0
173 Called program file not found in drive/directory
How do I have to link the program so that it includes all the objects contained in the static library even the ones not implicitly referenced?
Thanks.
Regards.
In order to link an object from a static library into an executable, when only a dynamic call is made in COBOL, you can use the -I option on the cob32 line and specify the symbol name. This will force it to link the object containing that symbol into your executable. Try something like:
cob32 -v -xU -o regards main.o -L . -lregards -I GOODBYE-WORLD
In order to link an object from a static library into an executable, when only a dynamic call is made in COBOL, you can use the -I option on the cob32 line and specify the symbol name. This will force it to link the object containing that symbol into your executable. Try something like:
cob32 -v -xU -o regards main.o -L . -lregards -I GOODBYE-WORLD
Hi Chris,
Correct. This is a possible solution. In our case, the static library has about 107 objects/routines, fulfilling, in addition, that the routine that is implemented in each object coincides with the filename without extension (.o). The solution found is to do it as follows :
1 # Set COBMODE to 64 for 64bit. Defaults to 32bit.
2 MODE=${COBMODE:-32}
3
4 cob$MODE -v -xU -o regards main.o $(ar t libregards.a | sed 's/\\.o//g' | sed 's/^/-I /g' | xargs echo) libregards.a
/usr/mtp62224/apps/helloworldv3>ar -tvf libregards.a
rw-rw-r-- 176/110 2048 Aug 9 12:30 2022 HELLO-WORLD.o
rw-rw-r-- 176/110 2072 Aug 9 12:30 2022 GOODBYE-WORLD.o
/usr/mtp62224/prue/apps/helloworldv3>ar t libregards.a | sed 's/\\.o//g' | sed 's/^/-I /g' | xargs echo
-I HELLO-WORLD -I GOODBYE-WORLD
/usr/mtp62224/apps/helloworldv3>build_regards_exec_linking_static_library.sh
cob32 -C use=/cralm/simep/prue/jobs/cobol.dir -v -xU -o regards main.o -I HELLO-WORLD -I GOODBYE-WORLD libregards.a
cob32: Entry points defined in module: main.o
*main
MAIN
/usr/mtp62224/apps/helloworldv3>nm regards | grep WORLD
08048d40 T GOODBYE0WORLD
08048d77 t GOODBYE-WORLD:0x0
08048da2 t GOODBYE-WORLD::init
08048c00 T HELLO0WORLD
08048c37 t HELLO-WORLD:0x0
08048c62 t HELLO-WORLD::init
0804b21c D _mFinfo_GOODBYE0WORLD
0804b19c D _mFinfo_HELLO0WORLD
0804b2c0 d p.GOODBYE0WORLD
0804b2a8 d p.HELLO0WORLD
/usr/mtp62224/apps/helloworldv3>regards
Entrada al programa principal...
Hello world!
Goodbye world!
I understand that the perfect solution would be to somehow indicate to the cob32 compiler that you want all the symbols contained in the static library(ar file) to be included.
Thanks a lot.
Regards.
Hi Chris,
Correct. This is a possible solution. In our case, the static library has about 107 objects/routines, fulfilling, in addition, that the routine that is implemented in each object coincides with the filename without extension (.o). The solution found is to do it as follows :
1 # Set COBMODE to 64 for 64bit. Defaults to 32bit.
2 MODE=${COBMODE:-32}
3
4 cob$MODE -v -xU -o regards main.o $(ar t libregards.a | sed 's/\\.o//g' | sed 's/^/-I /g' | xargs echo) libregards.a
/usr/mtp62224/apps/helloworldv3>ar -tvf libregards.a
rw-rw-r-- 176/110 2048 Aug 9 12:30 2022 HELLO-WORLD.o
rw-rw-r-- 176/110 2072 Aug 9 12:30 2022 GOODBYE-WORLD.o
/usr/mtp62224/prue/apps/helloworldv3>ar t libregards.a | sed 's/\\.o//g' | sed 's/^/-I /g' | xargs echo
-I HELLO-WORLD -I GOODBYE-WORLD
/usr/mtp62224/apps/helloworldv3>build_regards_exec_linking_static_library.sh
cob32 -C use=/cralm/simep/prue/jobs/cobol.dir -v -xU -o regards main.o -I HELLO-WORLD -I GOODBYE-WORLD libregards.a
cob32: Entry points defined in module: main.o
*main
MAIN
/usr/mtp62224/apps/helloworldv3>nm regards | grep WORLD
08048d40 T GOODBYE0WORLD
08048d77 t GOODBYE-WORLD:0x0
08048da2 t GOODBYE-WORLD::init
08048c00 T HELLO0WORLD
08048c37 t HELLO-WORLD:0x0
08048c62 t HELLO-WORLD::init
0804b21c D _mFinfo_GOODBYE0WORLD
0804b19c D _mFinfo_HELLO0WORLD
0804b2c0 d p.GOODBYE0WORLD
0804b2a8 d p.HELLO0WORLD
/usr/mtp62224/apps/helloworldv3>regards
Entrada al programa principal...
Hello world!
Goodbye world!
I understand that the perfect solution would be to somehow indicate to the cob32 compiler that you want all the symbols contained in the static library(ar file) to be included.
Thanks a lot.
Regards.
You can do this with the "litlink" directive (I also use another directive "nocase" to make it case-insensitive)
For example:
# ./bld.sh
helloworld.cbl:
goodbyeworld.cbl:
helloworld.cbl:
goodbyeworld.cbl:
# ./regards
Entrada al programa principal...
Hello world!
Goodbye world!
# cat bld.sh
cob -c helloworld.cbl goodbyeworld.cbl
cob -Z -o libregards.so helloworld.cbl goodbyeworld.cbl
cob -C litlink -C nocase -x -L. -lregards -o regards main.cbl
You can do this with the "litlink" directive (I also use another directive "nocase" to make it case-insensitive)
For example:
# ./bld.sh
helloworld.cbl:
goodbyeworld.cbl:
helloworld.cbl:
goodbyeworld.cbl:
# ./regards
Entrada al programa principal...
Hello world!
Goodbye world!
# cat bld.sh
cob -c helloworld.cbl goodbyeworld.cbl
cob -Z -o libregards.so helloworld.cbl goodbyeworld.cbl
cob -C litlink -C nocase -x -L. -lregards -o regards main.cbl
The library libregards must be a static library(ar file with helloworld.o and goodbyeworld.o objects). The mentioned options also work for static libraries?
The library libregards must be a static library(ar file with helloworld.o and goodbyeworld.o objects). The mentioned options also work for static libraries?
I am not an expert in this area but after some experimentation I find that passing the --whole-archive option to the system linker for that library appears to do what you want.
-Q "--whole-archive" -lregards -Q "--no-whole-archive"
I am not an expert in this area but after some experimentation I find that passing the --whole-archive option to the system linker for that library appears to do what you want.
-Q "--whole-archive" -lregards -Q "--no-whole-archive"
Hi Chis,
The proposed solution works perfectly.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>ar -tvf libregards.a
rw-rw-r-- 176/110 2048 Aug 9 12:30 2022 HELLO-WORLD.o
rw-rw-r-- 176/110 2072 Aug 9 12:30 2022 GOODBYE-WORLD.o
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>build_regards_exec_linking_static_library.sh
cob32 -C use=/cralm/simep/prue/jobs/cobol.dir -v -xU -o regards main.o -Q --whole-archive -L . -lregards -Q --no-whole-archive
cob32: Entry points defined in module: main.o
*main
MAIN
The final executable includes all the symbols defined in the static library.
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>nm regards | grep WORLD
08048d40 T GOODBYE0WORLD
08048d77 t GOODBYE-WORLD:0x0
08048da2 t GOODBYE-WORLD::init
08048c00 T HELLO0WORLD
08048c37 t HELLO-WORLD:0x0
08048c62 t HELLO-WORLD::init
0804b21c D _mFinfo_GOODBYE0WORLD
0804b19c D _mFinfo_HELLO0WORLD
0804b2c0 d p.GOODBYE0WORLD
0804b2a8 d p.HELLO0WORLD
And the regards program works successfully...
int-cob-d-01u:/cralm/simep/prue/apps/helloworldv3>regards
Entrada al programa principal...
Hello world!
Goodbye world!
And the call to the GOODBYE-WORLD routine resolves successfully, without error 173 - Called program file not found in drive/directory, even though it is not called explicitly.
Many thanks.
Regards.
Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.