TransWikia.com

GNUCOBOL with embedded sql runtime error : module 'OCESQLConnect' not found

Super User Asked by Shooter on November 14, 2021

I am currently trying to run a cobol pgm with embedded sql that calls database in postgresql. I am running (GnuCOBOL) 2.2.0 on cygwin.

I have followed steps in https://github.com/opensourcecobol/Open-COBOL-ESQL. I manage to exec all steps. However, when i run the pgm i get OCESQL Connect not found as following :
$ ./INSERTTBL
* INSERTTBL STARTED *
libcob: module ‘OCESQLConnect’ not found

I suspect it’s libocesql.so not created in /usr/local/lib during ‘make install’
but I am not sure why it’s not created. Hence I can;t add into env >> export COB_PRE_LOAD=/usr/local/lib/libocesql.so . For ld library, i have added under export LD_LIBRARY_PATH=/usr/local/lib.

Thanks.

2 Answers

On Windows 10 OS:

  1. Download esqlOC Component from http://www.kiska.net/opencobol/esql/

    Using the option: ESQL Preprocessor and Runtime binaries for Windows x86-64 (AMD-64) andx86 (win32)

    This link downloads the file BINARIES.ZIP

  2. Unzip the BINARIES.ZIP file in the folder where theOpenCobolIDE4.7.6

    EX: C:Program Files (x86)OpenCobolIDEGnuCOBOL

    The binaries folder containing the esqlOC components is included

Figure #1 Install binaries

  1. Include in the SQL COBOL sheet of the “Preferences” option in the IDE the new subfolder binaries in esqlOC folder: This inclusion is for the pre compiler to work on the program with extension".Sqb" (Cobol with SQL statements)

Figure #2 esqlOC Folder

  1. Also include the path to the binaries subfolder in the option COMPILER sheet"Preferences" in the IDE. Also include the extension ".SQB" in the Associatedextensions of this sheet.

Figure #3 Compiler Preferences

  1. Generate a new program cobol with extension .sqb (COBOL WITH EXEC SQL)

  2. Include the connection to the Database.

    a. Include the following working fields:

        EXEC SQL BEGIN DECLARE SECTION END-EXEC.
    01  HOSTVARS.
        05 BUFFER     PIC  X(1024).
        05 hVarD      PIC S9(5)V99.
        05 hVarC      PIC  X(50).
        05 hVarN      PIC 9 (12).
    
        EXEC SQL END DECLARE SECTION END-EXEC.
    

    b. Include in Procedure Division the following sentences:

*--------------------------------------------------------------------- *

  • CONNECT TO THE DATABASE

  • also possible with DSN: 'youruser / yourpasswd @ yourODBC_DSN'
    ----------------------------------------------------------------------

       STRING 'DRIVER = {MySQL ODBC 5.1 Driver};'
              'SERVER = localhost;'
              'PORT = 3306;'
              'DATABASE = database;'
              'USER = mysql user;'
              'PASSWORD = mysql password ;'
    

*------------------------------------------------- ---------------- *

  • example for DB specific ODBC parameter:
  • no compressed MySQL connection (would be the DEFAULT anyway)
  • ------------------------------------------------- ---------------- *
  •           'COMRESSED_PROTO = 0;'
       INTO BUFFER.
    
       EXEC SQLCONNECT TO: BUFFER
       END-EXEC.
    
  1. Compile the program that has .SQB extension. It will issue the following errors, but it is normal:

    "C:Program Files (x86)OpenCobolIDEGnuCOBOLbin/ld.exe: cannot find -locsql.libcollect2.exe: error: ld returned 1 exit status"

  2. Open the cobol program generated by the pre compiler with the .COB extension

  3. Only compile the program with the .COB extension without modifying it.

  4. Execute.

Answered by Eduardo A. Palmeyro on November 14, 2021

First of all: You need to download and install Open-COBOL-ESQL-1.2: Open-COBOL-ESQL-1.2.tar.gz

$ export CPPFLAGS="-I/opt/pgsql/include"
$ export LDFLAGS="-L/opt/pgsql/lib"
$ ./configure
$ make
$ sudo make install

Second: Export these Flags:

export COPY=/Users/francisco/Downloads/Open-COBOL-ESQL-1.2/copy
export SCR=/usr/local/share/gnucobol/copy
export OC_OBJ=/Users/francisco/Downloads/Open-COBOL-ESQL-1.2/dblib

Third: complile .cbl

ocesql random.cbl random.cob

Fourth: Make executable

cobc -x random.cob $OC_OBJ/ocdb.o $OC_OBJ/ocdblog.o $OC_OBJ/ocdbutil.o $OC_OBJ/ocesql.o $OC_OBJ/ocpgsql.o -I$COPY -I$SCR -locesql -lpq

Finally (crossing your fingers):

./random

Answered by Francisco Villavicencio on November 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP