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

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 I manage to exec all steps. However, when i run the pgm i get OCESQL Connect not found as following :
libcob: module ‘OCESQLConnect’ not found

I suspect it’s 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/ . For ld library, i have added under export LD_LIBRARY_PATH=/usr/local/lib.


Super User Asked by Shooter on November 14, 2021

2 Answers

2 Answers

On Windows 10 OS:

  1. Download esqlOC Component from

    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:

    01  HOSTVARS.
        05 BUFFER     PIC  X(1024).
        05 hVarD      PIC S9(5)V99.
        05 hVarC      PIC  X(50).
        05 hVarN      PIC 9 (12).

    b. Include in Procedure Division the following sentences:

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


  • 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;'
  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):


Answered by Francisco Villavicencio on November 14, 2021

Add your own answers!

Related Questions

“Deployment Target Options” absent in android studio

2  Asked on January 31, 2021 by dmitriy-potapov


Get latest winrar installer with cURL

2  Asked on January 31, 2021 by klaatu_nikto


How can I list all IPs in the connected network, through Terminal preferably?

9  Asked on January 30, 2021 by christopher-gwilliams


Prevent administrator from changing account types

2  Asked on January 30, 2021 by sigstackfault


Usage of pl sql developer tool

0  Asked on January 30, 2021 by sukhen_sql


Pages stuck connecting

1  Asked on January 30, 2021 by jazerix


Ping between subnets fails inconsistently

1  Asked on January 30, 2021 by kaybee


Set shortcut for eyedropper (color picker) in firefox

1  Asked on January 28, 2021 by persijn


Removing GRUB from a dual-boot setup

6  Asked on January 28, 2021 by user3409878


Ask a Question

Get help from others!

© 2021 All rights reserved.