Compiling/linking from Command Line and from Eclipse (Windows): Manage files obtained

[Migrated content. Thread originally posted on 14 December 2011]

We are currently working with RM / COBOL, and we set up a folder system that we like to keep when we come to work with Visual Cobol.

We have the following folders:

/ CPY
/ FUENTES
/ LST
/ OBJ

All Programs .CBL are in the /FUENTES folder. When you compile a program, the copies are obtained from /CPY folder, the .LST file generated goes to /LST folder, and the .COB goes to /OBJ.

I've been doing some testing with Visual Cobol Native and I have some doubts. My idea is to generate .SO files so that programs can be executed with the command cobrun, and to be called by other programs with CALL.

1)Compiling and linking from command line. With de command

(DES): aixlab0102: / FUENTES> cob -z -P Program1.cbl

I get the next files
Program1.idy
Program1.int
Program1.lst
Program1.o
Program1.so


Then I move "Program1.so" to /OBJ folder and "Program1.lst" to /LST folder; and I remove the rest of files. I do all of this manually; it would be possible to automatically perform this movements through some option of command cob or some compiler directives????



2)Compiling and linking from Visual Cobol Eclipse (Windows) for Visual Cobol Remote Projects

This type of project generates on the remote server a project folder, and a set of related files: cobolBuild, cobolProj .. I suppose that this structure cannot be different, isn’t it???? I would like to have only one .CBL file for project in /FUENTES folder...

In any case, there is any way that the .so and .lst files goes automatically to ./OBJ and ./LST folders when I build the project from Visual Cobol Eclipse (Windows)???

Thank you
  • Verified Answer

    The cob command line supports a "-o" argument that can specify where the final output goes. So if in this case you specify:
    cob -z -P Program1.cbl -o OBJ/Program1.so
    then the shared object will appear in the OBJ directory.
    The cob command line does not directly support automatic deletion of the .int or .idy output, or redirecting the listing output to a different file location. Most people achieve command line builds via build scripts of some description (makefiles or similar): the recommendation would be to automate the steps you describe in such a script.
  • >>2)Compiling and linking from Visual Cobol Eclipse (Windows) for Visual Cobol Remote Projects

    In answer to this part, by default an Eclipse project will put the output files into the 'New_Configuration.bin' directory which you could rename to 'obj' if that fits better. If you had generated a listing file, then depending on where you wanted it, you could take advantage of a post build step to move it to a more desirable location.
    The .cobolBuild and .cobolProj are required files which contain the project contents and Ant build instructions. If you want your source code in a different place, then you can create a sub directory under the project root and put your COBOL source there - it will be built as normal.