Menu

Compiling a main source program

2024-07-24
2024-07-25
  • Vedant Tewari

    Vedant Tewari - 2024-07-24

    I was wondering if there are any specific commands to link and compile a main program with its dependencies in GnuCOBOL

    In my case I am trying to do the following:

    gcc -o main main.c libcob/java.c libcob/common.c libcob/call.c libcob/cobcapi.c libcob/fileio.c libcob/intrinsic.c libcob/mlio.c libcob/move.c libcob/numeric.c libcob/reportio.c libcob/screenio.c libcob/strings.c libcob/termio.c -I./libcob -I. -I/usr/include/libxml2 -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -L/usr/lib/jvm/java-11-openjdk-amd64/lib/server -L/usr/local/lib -ljvm -lxml2 -lgmp -lncurses -lcob
    

    But there are more and more files I need to keep linking, so it keeps giving undefined errors

     
    • Mickey White

      Mickey White - 2024-07-25

      Well..... I don't see any GnuCOBOL programs in your example. When I need to have many GnuCOBOL subroutines and other called C subprograms or Objects, I use Dynamic linking with Shared Objects. I combine all the subroutines and subprograms into one .SO file. And use the COB_PRE_LOAD environment parameter : export COB_PRE_LOAD=$HOME/lib/mwoc.so
      My stand alone (executables) GnuCOBOL programs can call any of the subroutines.
      I don't use Static Linking for my subroutines.

       

      Last edit: Mickey White 2024-07-25

Anonymous
Anonymous

Add attachments
Cancel