Menu

dbpre GNUCOBOL with mysql

Anonymous
2015-06-07
2021-11-28
1 2 3 .. 5 > >> (Page 1 of 5)
  • Anonymous

    Anonymous - 2015-06-07

    someone please help.

    I am trying to use gnucobol with myqsl for the first and getting this error. libcob: Cannot find module 'MySQL_init'

     
    • Brian Tiffin

      Brian Tiffin - 2015-06-08

      Anon;

      Not enough information. Assuming GNU/Linux x86_64 with mariadb-server installed, for this answer.

      There will be better ways more permanent ways to fix this, but find libmysqlclient.so, and then,

      export LD_LIBRARY_PATH=the-path-to-libmysqlclient
      

      For instance on the Fedora 21 AMD 64 setup, it's

      export LD_LIBRARY_PATH=/usr/lib64/mysql
      

      Then try your application again.

      Cheers,
      Brian

       
  • Anonymous

    Anonymous - 2015-06-08

    I am using Redhat6.4 x86_64

     
    • Brian Tiffin

      Brian Tiffin - 2015-06-08

      The advice given should work for RedHat. Can't tell if you have tried it yet. If you can find libmysqlclient.so, set LD_LIBRARY_PATH, and see.

      If it works, we can dig in on finding a more resilient and permanent fix for you.

      if not, I'll be asking for some tracer rounds, ala strace.

      Have you tried LD_LIBRARY_PATH ?

      And perhaps read through

      http://opencobol.add1tocobol.com/gnucobol/#what-is-cob-library-path
      http://opencobol.add1tocobol.com/gnucobol/#how-do-i-use-ld-run-path-with-gnucobol
      http://opencobol.add1tocobol.com/gnucobol/#what-is-cob-pre-load

      and then look through for some examples in that same document. I had to muck around with link loader paths for the Ficl sample, Perl, and a few others.

      External link loaders for Dynamic Shared Objects is one of the trickiest bits regarding effective GnuCOBOL programming. It's a heady issue, but well worth the time as a programmer getting to grips with the details. Each OS and version thereof is rife with slightly different rules and assumptions.

      Cheers

       
  • Anonymous

    Anonymous - 2015-06-09

    Hi Brian,

    thanks for your help i have tried export LD_LIBRARY_PATH=/usr/lib/mysql
    unfortunately i am still getting the same error.

    libmysqlclient.so is in that path

     
  • Brian Tiffin

    Brian Tiffin - 2015-06-09

    Ok then, now.

    Can you post output logs for the compile (add -v switch to turn on verbose cobc)

    and then output from

    strace ./yourprogram 2>&1 | grep open
    

    Oh, and before that, try

    export COB_LDFLAGS='-Wl,--no-as-needed'
    

    then run your compile. If that fixes things, then it'll push the problem onto the dev team here to get that linkage hint change pushed out into the wild. But, from what I understand that should only effect GnuCOBOL on Canonical (Ubuntu based) distributions, but just in case.

    And, to speed up the process, Anon, this isn't meant to be mean, or anything, take a read over http://stackoverflow.com/help/how-to-ask for hints on how to request technical help. That article is written for StackOverflow, but the same advice applies to most boards.

    One point, on logs. Screen them. Make sure you aren't inadvertently including sensitive information, or details that may help a cracker get into your systems.

    We can offer better assistance, faster, given more information up front. It can avoid bouncing back and forth.

    Cheers

     

    Last edit: Brian Tiffin 2015-06-09
  • Anonymous

    Anonymous - 2015-06-11

    Hi brian

    i have managed to pass that by your help. i am getting a new error

    ./PCTB003B: error while loading shared libraries: libcob.so.4: cannot open shared object file: No such file or directory

     
    • Brian Tiffin

      Brian Tiffin - 2015-06-12

      Hmmm, that's weirder. Try

      sudo ldconfig
      

      to ensure your linker loader cache is refreshed. If the problem persists, then your local ld.so setup may need some tweaking.

      Those can be harder problems, due to the level of detail involved, but always a fixable thing.

      Cheers

       
  • Brian Tiffin

    Brian Tiffin - 2015-06-12

    One thing, RedHat is (not) famous for not including /usr/local in the default ld configuration.

    Try

    ldconfig -v 2>/dev/null | grep local
    

    if /usr/local/lib doesn't show up,

    add a file to /etc/ld.so.conf.d (I use usr_local.conf) and add

    /usr/local/lib
    

    as a single text line.
    Then run

    sudo ldconfig
    

    ala

    prompt$ cat /etc/ld.so.conf.d/usr_local.conf
    /usr/local/lib
    prompt$ sudo ldconfig
    

    Note: ldconfig is actually going to try and refresh the cache, another option for just looking is

    ld --verbose | grep SEARCH
    

    I'm not sure why RedHat decided to exclude /usr/local/lib from default installs. At least on Fedora, that dir is excluded from the dynamic link search path.

    Cheers

     

    Last edit: Brian Tiffin 2015-06-12
  • Anonymous

    Anonymous - 2015-06-12

    Hi Brian,

    i am also getting error.

    libcob: Cannot find module 'MySQL_init'

    ld --verbose | grep SEARCH
    SEARCH_DIR("/usr/x86_64-redhat-linux/lib64"); SEARCH_DIR("/usr/local/lib64"); SEARCH_DIR("/lib64"); SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/x86_64-redhat-linux/lib"); SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");

    Question.
    what is 'MySQL_init' and why am i getting this error?

     
  • Anonymous

    Anonymous - 2015-06-13

    More infor

    after running strace ./PCTB003B | grep open

    access("./MySQL_init.so", R_OK) = -1 ENOENT (No such file or directory)
    access("/usr/local/lib/gnu-cobol/MySQL_init.so", R_OK) = -1 ENOENT (No such file or directory)
    write(2, "libcob: ", 8libcob: ) = 8
    write(2, "Cannot find module 'MySQL_init'", 31Cannot find module 'MySQL_init') = 31
    write(2, "\n", 1
    ) = 1
    exit_group(1)

     
    • Brian Tiffin

      Brian Tiffin - 2015-06-16

      Make sure that the compile of PCTB003B, and components, all include the --no-as-needed linker flag.

      export COB_LDFLAGS='-Wl,--no-as-needed'
      

      if that helped before. And, have all the -l and -L options required.

      Safest to run all the options, on all the files, or detail the list, and if you are like me, get overwhelmed in voodoo, and resort to flailing.

      Have good,
      Brian

       
      • Simon Sobisch

        Simon Sobisch - 2015-06-16

        If you want to add -Wl,--no-as-needed to every linking I'd highly suggest to reconfigure and reinstall the runtime:

        ::bash
        ./configure LD_FLAGS='-Wl,--no-as-needed' # add all options here that you've used before - if necessary check config.log for the original configure line
        make
        make check
        make install
        

        This will lead to the flags being standard in COB_LDFLAGS, no need to set them each time.

        Simon

         
  • Brian Tiffin

    Brian Tiffin - 2015-06-14

    MySQL_init is a function inside libmysqlclient.so that prepares data structures for using the C application programming interface to the database.

    Going to have to ask for a compile session log this time

    prompt$ script
    Script started, file is typescript
    prompt$ (whatever commands you are typing,
             but add -v to cobc)
    prompt$ exit
    Script done, file is typescript
    

    Don't cut'n'paste the typescript file, but attach it instead. (Blue Add attachments link beside Post button) It'll be full of terminal control characters which will muck up on the forum displays here.

    Plus, think about getting an account here, you won't have to wait for moderators to notice and approve posts. https://sourceforge.net/user/registration

    Cheers,
    Brian

     

    Last edit: Brian Tiffin 2015-06-14
  • Oscar

    Oscar - 2015-06-28

    Hi Brian,

    Sorry for getting back to you late, past few weeks i was very busy. i have attached the script as you requested.

     
  • Oscar

    Oscar - 2015-06-29

    cobol version

    prompt$ cobc -V
    cobc (GNU Cobol) 2.0.0
    Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Keisuke Nishida
    Copyright (C) 2006-2012 Roger While
    Copyright (C) 2013-2015 Ron Norman
    Copyright (C) 2009,2010,2012,2014,2015 Simon Sobisch
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Built Jun 21 2015 07:46:30
    Packaged Mrz 29 2015 14:56:23 UTC
    C version "4.4.7 20120313 (Red Hat 4.4.7-3)"

     

    Last edit: Oscar 2015-06-29
  • Brian Tiffin

    Brian Tiffin - 2015-07-01

    Just a note Oscar; Unfortunately, my two main work stations both decided to give up the ghost a few days back, and it'll be hit and miss on getting GnuCOBOL works done for the next little while. Working off a USB stick at the moment, sans most of the normal dev tools. Not forgotten, just a temporary timing problem for working through a solution.

    Brian

     
  • Brian Tiffin

    Brian Tiffin - 2015-07-04

    Ok, first up

    Instead of

    ::text
    cobc -x -v PCTB003B.cob DBINFO
    

    you need to give the compiler a hint as to what libraries to search.

    Try

    ::text
    cobc -x -v PCTB003B.cob DBINFO -lmysqlclient
    

    Note the lack of lib in the -l option, -l adds the "lib" part to the filename, all on it's own; you know because linking isn't complicated enough already, so someone, back in the past, decided ln needed some extra voodoo. ;-)

    I'm also a little confused by the casing, mysql_init versus MySQL_init. Where did the camelcase version come from in this instance? Is it generated code or manually typed?

    Linker symbols are case sensitive, and mysql_init is the form in libmysqlclient.so

    That may only be a first step, the -lmysqlclient part, as there may be other search path related tweaks to follow. If you can, change

    CALL "MySQL_init" ...
    

    to

    CALL "mysql_init" ...
    

    This may take a few more back and forths to work out Oscar, I still don't have a completely setup development box, hopefully you are up for it.

    In the meanwhile, there is quite a bit of information (although not overly organized) scattered about this and older forums.

    http://sourceforge.net/p/open-cobol/discussion/help/thread/8831de3f/

    for one, which links to others, that includes some fixes; and Jim Currey posted some sample code at http://svn.wp0.org/add1/libraries/mysql4Windows4OpenCobol/

    These may give you hints.

    Correction

    Umm, and having just read a little more; the above advice is pretty much off the mark. dbpre by sanpontze is where you get MySQL_init from. Hrrrm, excuse the oversight on my part.

    You'll use gcc -c to produce an object file from the cobmysqlapi.c C file, then

    ::text
    dbpre PCTB003B -ts=3 -I./
    cobc -x PCTB003B.cob cobmysqlapi.o -L/usr/lib/mysql -lmysqlclient
    

    So, this goes deeper than the track I was on. See Mark's code and comments in the thread I linked above. He placed updates on GitHub. Careful, as László correctly pointed out, that while the intent seems to be there, there is no clear indication of rights to copy sanpontze's original code. Play with it at home perhaps, but it may take a little bit of effort and detective work to allow any kind of redistribution or legally sound dbpre usage.

    It may be better to dig in head first and read up on Sergey's preprocessor for ODBC esqlOC and the PostgreSQL preprocessor from Japan, ocESQL.

    (Or the Firebird engine, the chief technical officer for Firebird dug in and produced a working build demo) or Oracle. Or ... sqlite3, or...

    This highlights a big todo for GnuCOBOL We need to document all the various SQL angles and get to some form of sane place to build up from.

    And a by the by; MariaDB is a drop in replacement for MySQL. Monty seems much more likely to work hard for long term end user freedoms than Oracle may be inclined to. Well, that and PostgreSQL is a better database in my humble opinion. Firebird deserve far more attention than it currently enjoys as well.

    My real opinion, sans waffling. SQLite3 for light duty SQL, PostgreSQL for heavy duty, with pride of place going to good old COBOL ISAM records and keys for everything; light, mid-range and heavy duties.

    Sorry to sow even more confusion. The situation is not ideal at the moment.

    Cheers,
    Brian

     
  • Oscar

    Oscar - 2015-07-06

    Brian,

    Your a star. I digged a little bit deeper and decided to try this.

    cobc -x PCTB003B.cob DBINFOR cobmysqlapi.o -L/usr/lib64/mysql -lmysqlclient

    and guess what, it worked.

    Thanks Brian, i couldn't have done it without your help, i can now confirm that MYSQL with DBPRE on Linux Redhat6.4 x86_64 works like a charm.

    If you use a 64 bit machine like me better compile that way.

     

    Last edit: Oscar 2015-07-06
  • Brian Tiffin

    Brian Tiffin - 2015-07-08

    Nice to hear, Oscar.

    Have good,
    Brian

     
  • Anonymous

    Anonymous - 2017-02-10

    Hello,
    Help Please.
    I use ubuntu and open(gnu)cobol.
    I have downloaded PCTB003B.
    What folder should i put it in?
    how do I get the gcc compiler to compile it.
    How do I use it to write my sql in open cobol.
    I have mysql installed and working?
    A beginners guide please?

    rgds

    rob

     
    • Brian Tiffin

      Brian Tiffin - 2017-02-11

      What folder should i put it in?

      Any. Pick a working directory and have at it.

      how do I get the gcc compiler to compile it.

      Reading through this thread should help. Basically pass the file name along with application source to cobc.

      How do I use it to write my sql in open cobol.

      Umm, this is were your programming skills come in, there is a project space at

      https://sourceforge.net/projects/dbpre

      I have mysql installed and working?

      You'll need to ensure you have it installed and working, yes. With valid credentials.

      As a heads up, MariaDB might be a better starting point. It's a drop in replacement for mySQL, and is a little more open. Same original author, same command names and API, but more in line with free software. My's dad also has another daughter, Maria, and now they both have a database named after them.

      A beginners guide please?

      Vince, Jim and The_Piper have always been the go to people for this one. I'll hunt around for a starter kit sample and try to get it into the FAQ. For now, start here

      https://sourceforge.net/p/dbpre/code/HEAD/tree/

      The hosted README file walks you through the included example program

      Cheers,
      Brian

       
      • Vincent (Bryan) Coen

        Brian;

        Please create a directory below contrib / trunk / tools
        for JC-SQL-PreCompiler

        With me as admin {vcoen} create/read/write/delete etc permissions

        and I will upload the JCurrey pre-compiler that has been maintained by
        myself.

        [ Making it available to the community is with the explicit permission
        of Jim Currey ]
        .

        If you cannot do this then please ask whom ever can,
        Need to do this before I forget , again.

        Thanks,

        Vince

         
        • Brian Tiffin

          Brian Tiffin - 2017-02-11

          Simon holds those keys, Vince. It's better for controlled management, and worse, because it all ends up on his shoulders, on top of everything else.

          Cheers,
          Brian

           
          • Vincent (Bryan) Coen

            OK, sent to him.

            Thanks for reminding me - too busy programming to think straight :)

            Vince
            On 11/02/17 18:45, Brian Tiffin wrote:

            Simon holds those keys, Vince. It's better for controlled management,
            and worse, because it all ends up on his shoulders, on top of
            everything else.

            Cheers,
            Brian


             
1 2 3 .. 5 > >> (Page 1 of 5)

Anonymous
Anonymous

Add attachments
Cancel