Menu

GMP calls from COBOL fails to compile under 3.1, 3.2 and 4.0

2021-10-03
2021-10-04
  • László Erdős

    László Erdős - 2021-10-03

    Hi,

    I am trying to compile an old contribution under cygwin64:
    https://sourceforge.net/p/gnucobol/contrib/HEAD/tree/trunk/samples/prothsearch/

    I wrote this program with the GnuCOBOL version 2.2. It compiles and runs yet with 3.0.
    But it fails to compile with 3.1.2, with 3.2 and with 4.0. Same cygwin64 and same source code.

    There are always undefined references to the GMP functions. I tried to link GMP also
    with the parameters -L and -l, but it doesn't work.

    The last try with 4.0:

    $ cobc -info
    cobc (GnuCOBOL) 4.0-early-dev.0
    Copyright (C) 2021 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
    Built Oct 03 2021 18:33:28
    Packaged Oct 03 2021 12:42:36 UTC
    C version "11.2.0"

    build information
    build environment : x86_64-pc-cygwin
    CC : gcc
    C version : "11.2.0"
    CPPFLAGS :
    CFLAGS : -O2 -pipe -finline-functions -fsigned-char
    -Wall -Wwrite-strings -Wmissing-prototypes
    -Wno-format-y2k
    LD : /usr/x86_64-pc-cygwin/bin/ld.exe
    LDFLAGS :

    GnuCOBOL information
    COB_CC : gcc
    COB_CFLAGS : -pipe -I/usr/local/include -Wno-unused
    -fsigned-char -Wno-pointer-sign
    COB_DEBUG_FLAGS : -ggdb3 -fasynchronous-unwind-tables
    COB_LDFLAGS :
    COB_LIBS : -L/usr/local/lib -lcob -lm
    COB_CONFIG_DIR : /usr/local/share/gnucobol/config
    COB_COPY_DIR : /usr/local/share/gnucobol/copy
    COB_SCHEMA_DIR : /usr/local/share/gnucobol/schema
    COB_MSG_FORMAT : GCC
    COB_OBJECT_EXT : o
    COB_MODULE_EXT : dll
    COB_EXE_EXT : .exe
    64bit-mode : yes
    BINARY-C-LONG : 8 bytes
    endianness : little-endian
    native character set : ASCII
    extended screen I/O : ncursesw
    variable file format : 0
    sequential file handler : built-in
    indexed file handler : BDB
    mathematical library : GMP
    XML library : libxml2
    JSON library : json-c

    $ make
    cobc -c -free -O3 -fno-gen-c-decl-static-call prothtest.cob
    prothtest.cob: in section 'COMP-PROTH-NUMBER':
    prothtest.cob:561: warning: duplicate USING BY REFERENCE item 'WS-GMP-PROTH-NUMBER' [-Wothers]
    prothtest.cob:576: warning: duplicate USING BY REFERENCE item 'WS-GMP-PROTH-NUMBER-2' [-Wothers]
    prothtest.cob: in section 'SMALL-PRIMES-DIVISION-TEST':
    prothtest.cob:710: warning: duplicate USING BY REFERENCE item 'WS-GMP-PROTH-NUMBER-SQRT' [-Wothers]
    prothtest.cob: in section 'PROTH-PRIMALITY-TEST':
    prothtest.cob:946: warning: duplicate USING BY REFERENCE item 'WS-GMP-POWM-RESULT' [-Wothers]
    prothtest.cob:947: warning: duplicate USING BY REFERENCE item 'WS-GMP-POWM-RESULT' [-Wothers]
    prothtest.cob:963: warning: duplicate USING BY REFERENCE item 'WS-GMP-POWM-RESULT' [-Wothers]
    prothtest.cob:975: warning: duplicate USING BY REFERENCE item 'WS-GMP-POWM-RESULT' [-Wothers]
    prothtest.cob:992: warning: duplicate USING BY REFERENCE item 'WS-GMP-POWM-RESULT' [-Wothers]
    prothtest.cob: in section 'COMPUTE-MOD-PROTH-NUMBER':
    prothtest.cob:1083: warning: duplicate USING BY REFERENCE item 'WS-GMP-HELP-VAR' [-Wothers]
    prothtest.cob:1099: warning: duplicate USING BY REFERENCE item 'WS-GMP-HELP-VAR' [-Wothers]
    /tmp/cob18194_0.c: In function ‘prothtest_’:
    /tmp/cob18194_0.c:258:5: warning: implicit declaration of function ‘mpz_init2’ [-Wimplicit-function-declaration]
    258 | mpz_init2 (b_13, (cob_s32_t)400000000LL);
    | ^~~~~~~~~
    /tmp/cob18194_0.c:514:5: warning: implicit declaration of function ‘mpz_ui_pow_ui’ [-Wimplicit-function-declaration]
    514 | mpz_ui_pow_ui (b_13, (cob_s32_t)2LL, (cob_s32_t)(((unsigned int )(f_193.data + 4))));
    | ^~~~~~~~~~~~~
    /tmp/cob18194_0.c:537:5: warning: implicit declaration of function ‘mpz_set_ui’ [-Wimplicit-function-declaration]
    537 | mpz_set_ui (b_45, (cob_s32_t)(((unsigned int )(f_193.data))));
    | ^~~~~~~~~~
    /tmp/cob18194_0.c:549:9: warning: implicit declaration of function ‘mpz_cmp’ [-Wimplicit-function-declaration]
    549 | b_2 = mpz_cmp (b_13, b_45);
    | ^~~~~~~
    /tmp/cob18194_0.c:579:5: warning: implicit declaration of function ‘mpz_mul_ui’ [-Wimplicit-function-declaration]
    579 | mpz_mul_ui (b_17, b_13, (cob_s32_t)(((unsigned int )(f_193.data))));
    | ^~~~~~~~~~
    /tmp/cob18194_0.c:598:5: warning: implicit declaration of function ‘mpz_add_ui’ [-Wimplicit-function-declaration]
    598 | mpz_add_ui (b_17, b_17, (cob_s32_t)1LL);
    | ^~~~~~~~~~
    /tmp/cob18194_0.c:617:5: warning: implicit declaration of function ‘mpz_sub_ui’ [-Wimplicit-function-declaration]
    617 | mpz_sub_ui (b_21, b_17, (cob_s32_t)1LL);
    | ^~~~~~~~~~
    /tmp/cob18194_0.c:636:11: warning: implicit declaration of function ‘mpz_tdiv_q_ui’ [-Wimplicit-function-declaration]
    636 | b_2 = mpz_tdiv_q_ui (b_21, b_21, (cob_s32_t)2LL);
    | ^~~~~~~~~~~~~
    /tmp/cob18194_0.c:654:11: warning: implicit declaration of function ‘mpz_sizeinbase’ [-Wimplicit-function-declaration]
    654 | b_2 = mpz_sizeinbase (b_17, (cob_s32_t)10LL);
    | ^~~~~~~~~~~~~~
    /tmp/cob18194_0.c:729:11: warning: implicit declaration of function ‘mpz_jacobi’ [-Wimplicit-function-declaration]
    729 | b_2 = mpz_jacobi (b_37, b_17);
    | ^~~~~~~~~~
    /tmp/cob18194_0.c:827:11: warning: implicit declaration of function ‘mpz_divisible_ui_p’ [-Wimplicit-function-declaration]
    827 | b_2 = mpz_divisible_ui_p (b_45, (cob_s32_t)6LL);
    | ^~~~~~~~~~~~~~~~~~
    /tmp/cob18194_0.c:897:3: warning: implicit declaration of function ‘mpz_sqrt’ [-Wimplicit-function-declaration]
    897 | mpz_sqrt (b_41, b_17);
    | ^~~~~~~~
    /tmp/cob18194_0.c:1237:7: warning: implicit declaration of function ‘mpz_set’ [-Wimplicit-function-declaration]
    1237 | mpz_set (b_29, b_33);
    | ^~~~~~~
    /tmp/cob18194_0.c:1369:13: warning: implicit declaration of function ‘mpz_tstbit’ [-Wimplicit-function-declaration]
    1369 | b_2 = mpz_tstbit (b_21, (cob_s32_t)(((unsigned int )(b_109))));
    | ^~~~~~~~~~
    /tmp/cob18194_0.c:1382:5: warning: implicit declaration of function ‘mpz_mul’ [-Wimplicit-function-declaration]
    1382 | mpz_mul (b_29, b_29, b_29);
    | ^~~~~~~
    /tmp/cob18194_0.c:1440:9: warning: implicit declaration of function ‘mpz_mod’ [-Wimplicit-function-declaration]
    1440 | mpz_mod (b_29, b_29, b_17);
    | ^~~~~~~
    /tmp/cob18194_0.c:1592:5: warning: implicit declaration of function ‘mpz_tdiv_q_2exp’ [-Wimplicit-function-declaration]
    1592 | mpz_tdiv_q_2exp (b_49, b_29, (cob_s32_t)(((unsigned int )(f_193.data + 4))));
    | ^~~~~~~~~~~~~~~
    /tmp/cob18194_0.c:1616:5: warning: implicit declaration of function ‘mpz_tdiv_r_2exp’ [-Wimplicit-function-declaration]
    1616 | mpz_tdiv_r_2exp (b_53, b_29, (cob_s32_t)(((unsigned int )(f_193.data + 4))));
    | ^~~~~~~~~~~~~~~
    /tmp/cob18194_0.c:1640:11: warning: implicit declaration of function ‘mpz_tdiv_qr_ui’ [-Wimplicit-function-declaration]
    1640 | b_2 = mpz_tdiv_qr_ui (b_57, b_61, b_49, (cob_s32_t)(((unsigned int )(f_193.data))));
    | ^~~~~~~~~~~~~~
    /tmp/cob18194_0.c:1665:3: warning: implicit declaration of function ‘mpz_add’ [-Wimplicit-function-declaration]
    1665 | mpz_add (b_45, b_45, b_53);
    | ^~~~~~~
    /tmp/cob18194_0.c:1704:3: warning: implicit declaration of function ‘mpz_sub’ [-Wimplicit-function-declaration]
    1704 | mpz_sub (b_29, b_45, b_57);
    | ^~~~~~~
    /tmp/cob18194_0.c:1823:11: warning: implicit declaration of function ‘gmp_fprintf’; did you mean ‘vfprintf’? [-Wimplicit-function-declaration]
    1823 | b_2 = gmp_fprintf (((unsigned char ) (b_123)), content_2.data, b_17);
    | ^~~~~~~~~~~
    | vfprintf
    /tmp/cob18194_0.c:1855:20: warning: passing argument 1 of ‘fclose’ from incompatible pointer type [-Wincompatible-pointer-types]
    1855 | b_2 = fclose ((
    (unsigned char ) (b_123)));
    | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | |
    | unsigned char *
    In file included from /tmp/cob18194_0.c:8:
    /usr/include/stdio.h:191:17: note: expected ‘FILE ’ but argument is of type ‘unsigned char
    191 | int fclose (FILE );
    | ^~~~~~
    /tmp/cob18194_0.c:2075:20: warning: passing argument 1 of ‘fclose’ from incompatible pointer type [-Wincompatible-pointer-types]
    2075 | b_2 = fclose ((
    (unsigned char
    ) (b_140)));
    | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | |
    | unsigned char *
    In file included from /tmp/cob18194_0.c:8:
    /usr/include/stdio.h:191:17: note: expected ‘FILE ’ but argument is of type ‘unsigned char
    191 | int fclose (FILE );
    | ^~~~~~
    /tmp/cob18194_0.c:2375:11: warning: implicit declaration of function ‘gmp_fscanf’; did you mean ‘vfscanf’? [-Wimplicit-function-declaration]
    2375 | b_2 = gmp_fscanf ((
    (unsigned char ) (b_140)), content_2.data, b_33);
    | ^~~~~~~~~~
    | vfscanf
    /tmp/cob18194_0.c:2405:20: warning: passing argument 1 of ‘fclose’ from incompatible pointer type [-Wincompatible-pointer-types]
    2405 | b_2 = fclose ((*(unsigned char
    ) (b_140)));
    | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | |
    | unsigned char *
    In file included from /tmp/cob18194_0.c:8:
    /usr/include/stdio.h:191:17: note: expected ‘FILE ’ but argument is of type ‘unsigned char
    191 | int fclose (FILE *);
    | ^~~~~~
    /tmp/cob18194_0.c:2767:3: warning: implicit declaration of function ‘mpz_clear’ [-Wimplicit-function-declaration]
    2767 | mpz_clear (b_13);
    | ^~~~~~~~~
    cobc -x -free -O3 prothsearch.cob prothtest.o
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0xaa8): undefined reference to mpz_set' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0xe79): undefined reference tompz_init2'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0xee5): undefined reference to mpz_init2' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0xf60): undefined reference tompz_init2'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0xfd0): undefined reference to mpz_init2' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1043): undefined reference tompz_init2'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x10ba): more undefined references to mpz_init2' follow /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x14c1): undefined reference tompz_ui_pow_ui'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x154f): undefined reference to mpz_set_ui' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x15ae): undefined reference tompz_cmp'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1682): undefined reference to mpz_mul_ui' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x16fd): undefined reference tompz_add_ui'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1785): undefined reference to mpz_sub_ui' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x17fd): undefined reference tompz_tdiv_q_ui'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1884): undefined reference to mpz_sizeinbase' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x190f): undefined reference tompz_sizeinbase'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1a31): undefined reference to mpz_set_ui' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1a8b): undefined reference tompz_jacobi'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1b67): undefined reference to mpz_set_ui' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1bc7): undefined reference tompz_cmp'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1c57): undefined reference to mpz_sub_ui' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1cd4): undefined reference tompz_divisible_ui_p'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1d5d): undefined reference to mpz_add_ui' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1dd0): undefined reference tompz_divisible_ui_p'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1e70): undefined reference to mpz_sqrt' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1eee): undefined reference tompz_add_ui'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1f93): undefined reference to mpz_set_ui' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x1fec): undefined reference tompz_cmp'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x209d): undefined reference to mpz_set_ui' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x210e): undefined reference tompz_set_ui'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x347b): undefined reference to gmp_fprintf' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x3ac2): undefined reference tompz_tstbit'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x3b3b): undefined reference to mpz_mul' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x3bc7): undefined reference tompz_cmp'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x3ca1): undefined reference to mpz_tdiv_q_2exp' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x3d2f): undefined reference tompz_tdiv_r_2exp'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x3dc4): undefined reference to mpz_tdiv_qr_ui' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x3e36): undefined reference tompz_mul'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x3e96): undefined reference to mpz_add' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x3ef9): undefined reference tompz_cmp'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x3f5a): undefined reference to mpz_add' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x3fc4): undefined reference tompz_sub'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x429c): undefined reference to gmp_fprintf' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x4478): undefined reference tompz_mod'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x475a): undefined reference to mpz_clear' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x47ad): undefined reference tompz_clear'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x4806): undefined reference to mpz_clear' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x4862): undefined reference tompz_clear'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x48bc): undefined reference to mpz_clear' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x4918): more undefined references tompz_clear' follow
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x5081): undefined reference to mpz_mul' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x5285): undefined reference tompz_divisible_ui_p'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x57d7): undefined reference to mpz_add_ui' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: prothtest.o:cob18194_0.c:(.text+0x5c10): undefined reference togmp_fscanf'
    collect2: error: ld returned 1 exit status
    make: *** [makefile:8: prothsearch.exe] Error 1

    Thanks,

    László

     
    • Simon Sobisch

      Simon Sobisch - 2021-10-03

      It is good that the link without options does fail now, otherwise each COBOL module would have a dependency on a specific GMP/MPIR ABI and possible even library version.
      GnuCOBOL 3 correctly does not link GMP/curses/BDB/... to the modules, they only have an indirect dependency to those via libcob.

      The approach with -l and (if installed in a "special" directory) -L (should commonly not be needed) was the correct one, the command line showed here does not specify -lgmp (check cobcrun --info for the correct library name).

      It commonly should not be reasonable to fopen/fclose from COBOL, you may want to adjust the source.
      In any case you may want to force-include gmp and/or other C header files (please check the forum, I think the last time this came up was the DB2 preprocessor). This will fix all the " implicit declaration of function" warnings and also help the linker to search for the correct function prototypes and not try to get "unmatching" ones. If the functions are macros (not unlikely with GMP) that will be also needed if you don't want to change the CALLs to whatever function is really exported. GC3 also does not need to include the GMP header any more, older versions from 2.0 on did that.

      In general I'd suggest to have a C wrapper for the GMP functions and link it together with the program, something like cobc prog.cob gmpcalls.c -lgmp. This way you can do the C part "clean" and also have the COBOL program using clean static CALLs without warnings.

      Simon

       
  • László Erdős

    László Erdős - 2021-10-04

    Hi Simon,

    thank you for your hints, I will correct the program.

    László

     

Anonymous
Anonymous

Add attachments
Cancel