Highlighted
Absent Member.
Absent Member.
3701 views

Compile OO from command line ?

Jump to solution

[Migrated content. Thread originally posted on 31 January 2011]

Can source code with OO, methods, etc, be compiled from the command line, or does it have to be done in Visual Studio ?
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Compile OO from command line ?

Jump to solution
Sure, you can use the command line as normal, you just need to use the right directives, for example ilgen for .Net and jvmgen for the JVM, for example:


>cobol Program1.cbl ilgen;
Micro Focus COBOL
Version 1.2.00054 Copyright (C) 1984-2010 Micro Focus (IP) Limited.
* Checking complete with no errors

>program1
Hello World

>cobol Program2.cbl jvmgen;
Micro Focus COBOL
Version 1.2.00054 Copyright (C) 1984-2010 Micro Focus (IP) Limited.
* Checking complete with no errors

>java Program2
Hello World

>type Program1.cbl
       invoke type System.Console::WriteLine("Hello World")

>type Program2.cbl
       invoke type java.lang.System::out::println("Hello World")


You can also use the project's created in visual studio from the command line too via the 'msbuild' command..

Do you have any reason why you need to use the command line?

View solution in original post

0 Likes
5 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Compile OO from command line ?

Jump to solution
Sure, you can use the command line as normal, you just need to use the right directives, for example ilgen for .Net and jvmgen for the JVM, for example:


>cobol Program1.cbl ilgen;
Micro Focus COBOL
Version 1.2.00054 Copyright (C) 1984-2010 Micro Focus (IP) Limited.
* Checking complete with no errors

>program1
Hello World

>cobol Program2.cbl jvmgen;
Micro Focus COBOL
Version 1.2.00054 Copyright (C) 1984-2010 Micro Focus (IP) Limited.
* Checking complete with no errors

>java Program2
Hello World

>type Program1.cbl
       invoke type System.Console::WriteLine("Hello World")

>type Program2.cbl
       invoke type java.lang.System::out::println("Hello World")


You can also use the project's created in visual studio from the command line too via the 'msbuild' command..

Do you have any reason why you need to use the command line?

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Compile OO from command line ?

Jump to solution
spgennard originally wrote:
Do you have any reason why you need to use the command line?


Old habits die hard 🙂
As I am still getting used to VS, and learning OO concepts,
I tend to use vim to type up something short, and then compile
from the command line.

As it happens, the code I was compiling was code I think you wrote
(same user name) and posted (on StackOverflow) !

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Compile OO from command line ?

Jump to solution
One of the main advantages in using Visual Studio is the independent and extensible build system AKA msbuild.

If you create your project using Visual Studio, you can also build it on the command line using msbuild because the project file we create is in fact an msbuild makefile.

msbuild mycobolproject.cblproj

Keeping your build configuration in one place whether you're working in the IDE or from the command line makes life a lot simpler.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Compile OO from command line ?

Jump to solution
One other thing worth mentioning...

One of the COBOL settings on the COBOL property page is "generate directives file".

With this set, the IDE will create a .dir file in the project root directory which you can also use to compile your application.

cobol source.cbl use(project_name.dir) ;
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Compile OO from command line ?

Jump to solution
colemanj originally wrote:
As I am still getting used to VS, and learning OO concepts,
I tend to use vim to type up something short, and then compile
from the command line.


Good to know I'm not the only person in the world using Vim to edit Visual COBOL.

For quick&dirty programs - typically just to test out some obscure corner of VisCOB .NET syntax - I often just compile with "cobol ... ilgen" (sometimes wrapped in a simple Makefile). For real projects, I use Visual Studio to create the project file, but I typically edit in Vim and build using msbuild on the command line.

For when I do have to work in Visual Studio, I've installed Jared Parsons' VsVim extension for Visual Studio, which provides a pretty good Vim emulation mode in the VS editor.

I've also customized my Vim installation with a COBOL syntax file that recognizes more of the .NET syntax, and a hack I made to the Vim sources to better handle the COBOL A-margin for fixed/variable formatted source. (My normal inclination would be to use free format, but a lot of the source I work with is variable-format and shared with other developers.) If you're interested in those, drop me an email at michael.wojcik@microfocus.com.
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.