Skip to main content

Hi , I'm trying to compile Visual Cobol and call them from Linux Shell ,

I'm new to Visual Cobol.... Here's 2 questions

1.  I created a [COBOL Project] and Newed 3 COBOL Programs named Program1~3,

     and [Run As] - [COBOL Application]. but it only executed Program1.

     How can I execute Program2 or Program3 directly? Like I can run a Java Program if It's a Main[] Class ?

2.  How to execute COBOL Program from Linux Shell ?

     Compile Java Programs made .class files and I can run it with Shell Command. What's the runable file for Visual Cobol ?

I'm reading this document

https://www.microfocus.com/documentation/visual-cobol/vc70/EclUNIX/GUID-8D6B7358-AC35-4DAF-A445-607D8D97EBB2.html

and maybe you can point out which part should I read ?

Thanks, waiting for your response.

Hi , I'm trying to compile Visual Cobol and call them from Linux Shell ,

I'm new to Visual Cobol.... Here's 2 questions

1.  I created a [COBOL Project] and Newed 3 COBOL Programs named Program1~3,

     and [Run As] - [COBOL Application]. but it only executed Program1.

     How can I execute Program2 or Program3 directly? Like I can run a Java Program if It's a Main[] Class ?

2.  How to execute COBOL Program from Linux Shell ?

     Compile Java Programs made .class files and I can run it with Shell Command. What's the runable file for Visual Cobol ?

I'm reading this document

https://www.microfocus.com/documentation/visual-cobol/vc70/EclUNIX/GUID-8D6B7358-AC35-4DAF-A445-607D8D97EBB2.html

and maybe you can point out which part should I read ?

Thanks, waiting for your response.

The default build target type for a new project in Eclipse is to compile all programs and link them to a single executable. So if you have Program1.cbl, Program2.cbl and Program3.cbl it will generate 3 different object files and link them into the single executable Program1. I think what you desire is to have each of these programs compiled and linked separately so that you end up with 3 separate executable files that can be each run on their own.

To do this right-click on the project name and select Properties. Under properties open up Micro Focus-->Bild Configurations-->Link tab. Under target type change this to All executable files. When your project is rebuilt you will have 3 separate executable files that can be run separately. These executable files can be run in the same manner as any Linux executable from a shell script or from a command line, etc.

The link in the docs that covers this in detail woiuld probably be in the sections here


The default build target type for a new project in Eclipse is to compile all programs and link them to a single executable. So if you have Program1.cbl, Program2.cbl and Program3.cbl it will generate 3 different object files and link them into the single executable Program1. I think what you desire is to have each of these programs compiled and linked separately so that you end up with 3 separate executable files that can be each run on their own.

To do this right-click on the project name and select Properties. Under properties open up Micro Focus-->Bild Configurations-->Link tab. Under target type change this to All executable files. When your project is rebuilt you will have 3 separate executable files that can be run separately. These executable files can be run in the same manner as any Linux executable from a shell script or from a command line, etc.

The link in the docs that covers this in detail woiuld probably be in the sections here

Thanks for the response.

I've complied 3 executable files and executed them by running [./] command .

But as long as compiled to executable files, seems I cannot call them from another Cobol Program.

Now I have 2 Main Programs named Program1 and Program2,

and 2 Sub Programs named Program20 and Program21,

can I complied them that makes 4 executable files ,

and Program1 call Program20 also effected ?

Maybe I should use [Callable Shared Objects] but I don't know where and how to execute [cob -z] command ....

Waiting for your response , thank you.


The default build target type for a new project in Eclipse is to compile all programs and link them to a single executable. So if you have Program1.cbl, Program2.cbl and Program3.cbl it will generate 3 different object files and link them into the single executable Program1. I think what you desire is to have each of these programs compiled and linked separately so that you end up with 3 separate executable files that can be each run on their own.

To do this right-click on the project name and select Properties. Under properties open up Micro Focus-->Bild Configurations-->Link tab. Under target type change this to All executable files. When your project is rebuilt you will have 3 separate executable files that can be run separately. These executable files can be run in the same manner as any Linux executable from a shell script or from a command line, etc.

The link in the docs that covers this in detail woiuld probably be in the sections here

Comment Updated.

I found your answer which near to my issue 7 year ago....I have to create an [.int] file for a subprogram, right ?

So I created 2 Cobol Projects ,

1.  Project1 contains all Main-Programs complied to [All Executable Files],

2.  Project2 contains all Sub-Programs complied to [All Int/Gnt Files],

3.  Right-Click on Project1 [Built Path] - [Projects] and add Project2

4.  Right-Click on Project1 [Project Reference] and check Project2

Sub-Programs did made [.int] files. But when I try to execute a main-program with call statement,

got an error  [Called program file not found in drive/directory]

So I copy [.int] file to Project1 MANUALLY. and it's all good...

Seems I'm closing to the answer...Here's the question

(1) I think I don't have to copy [.int] file manually everytime... How to reference it automatically?

(2) Is this the only way to compile Main-Program and Sub-Program?

     I hope a Sub-Program (called from other Program) could be an executable file too ... No way ?

Waiting for your response. Thank you


Comment Updated.

I found your answer which near to my issue 7 year ago....I have to create an [.int] file for a subprogram, right ?

So I created 2 Cobol Projects ,

1.  Project1 contains all Main-Programs complied to [All Executable Files],

2.  Project2 contains all Sub-Programs complied to [All Int/Gnt Files],

3.  Right-Click on Project1 [Built Path] - [Projects] and add Project2

4.  Right-Click on Project1 [Project Reference] and check Project2

Sub-Programs did made [.int] files. But when I try to execute a main-program with call statement,

got an error  [Called program file not found in drive/directory]

So I copy [.int] file to Project1 MANUALLY. and it's all good...

Seems I'm closing to the answer...Here's the question

(1) I think I don't have to copy [.int] file manually everytime... How to reference it automatically?

(2) Is this the only way to compile Main-Program and Sub-Program?

     I hope a Sub-Program (called from other Program) could be an executable file too ... No way ?

Waiting for your response. Thank you

Hello Zhaing Xin,

 

As you've discovered, the COBOL runtime will search for several subprogram types, including .int files, when trying to invoke a COBOL program. You could continue to use .int files in your second project, but since you are building to native file types, you can also build the subprograms to callable shared objects (I see you referenced this idea in an earlier post). You can build to callable shared objects by changing the target type in your subprograms project from All Int/Gnt Files to All Native Library Files. On Unix/Linux platforms, this creates a .so file for each program in that project.

 

Next, you do not need to copy any files from the subprogram project to your main project. Instead, you should configure your main programs project so that it has a dependency on the subprogram project - this allows the subprograms to be found when called. Here is a link to the Documentation that mentions this.

 

To answer your other question, subprograms cannot be invoked as main programs.


Hello Zhaing Xin,

 

As you've discovered, the COBOL runtime will search for several subprogram types, including .int files, when trying to invoke a COBOL program. You could continue to use .int files in your second project, but since you are building to native file types, you can also build the subprograms to callable shared objects (I see you referenced this idea in an earlier post). You can build to callable shared objects by changing the target type in your subprograms project from All Int/Gnt Files to All Native Library Files. On Unix/Linux platforms, this creates a .so file for each program in that project.

 

Next, you do not need to copy any files from the subprogram project to your main project. Instead, you should configure your main programs project so that it has a dependency on the subprogram project - this allows the subprograms to be found when called. Here is a link to the Documentation that mentions this.

 

To answer your other question, subprograms cannot be invoked as main programs.

I think I've got the basic rules for Creating or Running Visual Cobol Project.

Thanks for all the kindly response.