Menu

Creating .exe or .dll from .c code.

David Wall
2021-08-06
2021-08-06
  • David Wall

    David Wall - 2021-08-06

    If I have an existing GnuCOBOL setup on my C drive as follows:
    C:\COBOL
    C:\COBOL\BIN
    C:\COBOL\CONFIG
    C:\COBOL\COPY
    C:\COBOL\INCLUDE
    C:\COBOL\LIB
    C:\COBOL\LIBEXEC

    In other words - a standard (minimal) GnuCOBOL in folder COBOL together with its subdirectories.

    I can execute commands like: COBC -x TEST.COB which produces a standard TEST.EXE file.

    I can also create the .c source at the same time by saying: COBC -C TEST.COB

    What I would like to know is how to do the reverse - ie: I have the TEST.C & TEST.C.H & TEST.C.L.H files from the above but how/what command to give COBC to create the .exe.

    Or is it not possible with cobc & has to be done with GCC - in which case - where do all the .c files have to go?.

     
    • Simon Sobisch

      Simon Sobisch - 2021-08-06

      The manual says that you can mix COBOL, object and C files to your liking - and also can use only one of those (commonly COBOL); so the answer is cobc -x TEST.c (note: will only work correctly if the C source has a main, which is happening if you've created it with cobc -x TEST.cob before; if you want a module then you currently need an entry point that matches the source-name [PROGRAM-ID = file name]).

       
  • David Wall

    David Wall - 2021-08-06

    Thanks again Simon - I didn't realise Cobc could do that -

    I had it in my mind that I 'had' to go thru GCC.

    I'm going to have a play around & see what I can do -
    I'm trying to be able to recreate a .exe from its .c code after some changes I want to make
    - I'm trying to see where that Isam error occurs in a .exe but not in a .dll.

     

Anonymous
Anonymous

Add attachments
Cancel