Menu

I'm trying to create projects in subfolders but I can not get compile command to find the subfolders the contains the cobol programmes

2021-08-07
2021-08-24
  • Graham Knight

    Graham Knight - 2021-08-07

    Hi,
    I'm using win10 and cobc 3.1-rc1 (30jun2020)
    When I use the following command
    "cobc -x -Wall -debug -fnotrunc -I c:\GC31B-64-VBI\proj-copy -L c:\GC31B-64-VBI\proj-cob -t LOADDADF.lst LOADDADF.cob"
    the cobc option finds the -I for copybook/includes files but the -L does not not find cobol files. The only way to get a clean compile is to compile on the c:\GC31B-64-VBI\proj-cob subdirectory.
    Question, Am I using the -L option correctly? If not how do I compile the programmes in the subdirectory?
    I found the information on the compile options in the cobc-help.txt file.
    PS I have submitted this before but I was logged in.

     
    • Arnold Trembley

      Arnold Trembley - 2021-08-07

      I prefer NOT to put libraries in the cobc compile command. This is what I do instead on Windows.

      I open a CMD.EXE shell in the compiler directory. Then I run the "set_env.cmd" file to update the PATH and set all the environment variables. For an MSYS2 (MinGW 64-bit) compiler, I would run the "\bin\cobenv.cmd" script instead. These environment variable changes are TEMPORARY, and will be forgotten when the CMD.EXE shell is closed.

      You can make permanent changes to your PATH and environment variables, but that can cause problems if you need to move your GnuCOBOL compiler to a different location, or upgrade to a newer version, or if you want to support multiple versions of GnuCOBOL compilers for the same Windows user. Therefore, I prefer to use temporary environment variables for the current CMD.EXE session, but the choice is up to you.

      In actual practice, I use windows shortcuts to the "set_env.cmd" script, and it leaves the CMD.EXE shell open.

      Then I change to the directory where the COBOL source code is located using a CD command (for example, something like "cd c:\cobsorc"). Then I run the gcx.cmd script which has a simpler cobc command.

      The "set_env.cmd", "cobenv.cmd", and "gcx.cmd" scripts can all be customized for your local environment. You can also choose to put the library paths in those scripts as needed, but I have never been able to get the syntax right and the cobc command line gets too long for my taste.

      I hope that helps.

      Kind regards,

      P.S. You should edit the "gcx.cmd" script included with the MinGW buids, because it assumes you are in the GnuCOBOL compiler folder, and calls the "set_env.cmd" script to set PATH and environment variables. This is bad, because you shouldn't use the compiler folder to store your COBOL source and compiled programs.

       

      Last edit: Arnold Trembley 2021-08-07
      • Graham Knight

        Graham Knight - 2021-08-07

        Thanks Arnold,

        I understand in theory but you send an example of using temporary environment variables for the current CMD.EXE session. I have .bat command that does the cd to the directory and running the set_env.cmd. I could just add them to that bat file.

        Thank you very much for helping me.

        Graham.

         

        Last edit: Simon Sobisch 2021-08-24
  • Graham Knight

    Graham Knight - 2021-08-08

    Thanks Arnold,
    Thanks for for your help. I think I've worked out what to do with your help.
    Graham.

     
  • Simon Sobisch

    Simon Sobisch - 2021-08-24

    -I specifies an include path (mainly copybooks), -L specifies a library path.
    You look for a "source path", but there's no such option (I wonder if there is in any COBOL compiler), so it is either:

    rem direct specification, note: will hard-wire the full path into the module
    cobc -x -Wall -debug -fnotrunc -I "c:\GC31B-64-VBI\proj-copy" -t LOADDADF.lst "c:\GC31B-64-VBI\proj-cob\LOADDADF.cob"
    
    rem temporary switch to source directory, but then need to use the old path for the listing and output file
    set CURCD=%CD%
    pushd c:\GC31B-64-VBI\proj-cob
    cobc -x -Wall -debug -fnotrunc -I "c:\GC31B-64-VBI\proj-copy" -t "%CURCD%\LOADDADF.lst" -o "%CURCD%\LOADDADF.exe" LOADDADF.cob
    popd
    
     

Anonymous
Anonymous

Add attachments
Cancel