Menu

Compiler error in Windows - include: Invalid argument

Jim Horton
2021-06-10
2021-06-11
  • Jim Horton

    Jim Horton - 2021-06-10

    I'm trying to compile my first program. I have everything in a batch file. I get the error:
    gcc: error: Ic:\gnucobol\BDB2\include: Invalid argument

    any assistance would be great.

    echo on
    
    rem Compile a COBOL program
    
    rem are env strings already defined? (tried using () here, but it failed so goto it is
    
    if NOT "%COB_MAIN_DIR%" == "" goto cont
    
    rem define env strings
    
    set COB_MAIN_DIR=c:\gnucobol\BDB2\
    set COB_CONFIG_DIR=%COB_MAIN_DIR%config
    set COB_COPY_DIR=%COB_MAIN_DIR%copy
    set COB_CFLAGS=I" %COB_MAIN_DIR%include" %COB_CFLAGS%
    set COB_LDFLAGS=L" %COB_MAIN_DIR%lib" %COB_LDFLAGS%
    set COB_LIBRARY_PATH=%COB_MAIN_DIR%extras
    set PATH=%COB_MAIN_DIR%bin;%PATH%
    
    :cont
    
    rem Start the compiler
    
    cobc -x hello.cbl
    
     

    Last edit: Simon Sobisch 2021-06-10
  • Simon Sobisch

    Simon Sobisch - 2021-06-10

    You'd want to at least use

    -set COB_CFLAGS=I" %COB_MAIN_DIR%include" %COB_CFLAGS%
    -set COB_LDFLAGS=L" %COB_MAIN_DIR%lib" %COB_LDFLAGS%
    +set COB_CFLAGS=-I"%COB_MAIN_DIR%include" %COB_CFLAGS%
    +set COB_LDFLAGS=-L"%COB_MAIN_DIR%lib" %COB_LDFLAGS%
    

    but possibly even

    +set "COB_CFLAGS=-I"%COB_MAIN_DIR%include" %COB_CFLAGS%"
    +set "COB_LDFLAGS=-L"%COB_MAIN_DIR%lib" %COB_LDFLAGS%"
    

    to reduce the amount of issues you can get if those flags already contain a parenthesis or quotes or...

    Note: if you use Arnold's builds you can make that much more simpler:

    @echo off
    c:\gnucobol\BDB2\set_env.cmd cobc -x hello.cbl
    

    Nothing more needed :-)

    For older versions of his builds:

    @echo off
    rem set environment vars
    c:\gnucobol\BDB2\set_env.cmd
    
    rem start the compiler
    cobc -x hello.cbl
    

    and likely you'd want to replace hello.cbl by %1.cbl (if you want to pass it as argument) or by %1 if you want to be able to "drop" the file onto the bat file.

    ... just a note: if you want a nice IDE environment: install VSCodium and then drop it to the set_env.cmd - you then can directly use cobc -x hello.cbl in its integrated terminal and can also add "build" tasks that will do this for example for the active file, showing you the errors/warnings/infos in the problem pane and also in the editor window.

     
  • Jim Horton

    Jim Horton - 2021-06-11

    Thanks Simon. I finally got it to compile, with your help. I now have a bat file that will compile my code. Thanks!

     
    👍
    1

Anonymous
Anonymous

Add attachments
Cancel