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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
exportCOB_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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
someone please help.
I am trying to use gnucobol with myqsl for the first and getting this error. libcob: Cannot find module 'MySQL_init'
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,
For instance on the Fedora 21 AMD 64 setup, it's
Then try your application again.
Cheers,
Brian
I am using Redhat6.4 x86_64
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
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
Ok then, now.
Can you post output logs for the compile (add -v switch to turn on verbose cobc)
and then output from
Oh, and before that, try
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
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
Hmmm, that's weirder. Try
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
One thing, RedHat is (not) famous for not including /usr/local in the default ld configuration.
Try
if /usr/local/lib doesn't show up,
add a file to /etc/ld.so.conf.d (I use usr_local.conf) and add
as a single text line.
Then run
ala
Note: ldconfig is actually going to try and refresh the cache, another option for just looking is
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
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?
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)
Make sure that the compile of PCTB003B, and components, all include the --no-as-needed linker flag.
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
If you want to add -Wl,--no-as-needed to every linking I'd highly suggest to reconfigure and reinstall the runtime:
This will lead to the flags being standard in COB_LDFLAGS, no need to set them each time.
Simon
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
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
Hi Brian,
Sorry for getting back to you late, past few weeks i was very busy. i have attached the script as you requested.
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
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
Ok, first up
Instead of
you need to give the compiler a hint as to what libraries to search.
Try
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
to
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
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
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
Nice to hear, Oscar.
Have good,
Brian
View and moderate all "Help getting started" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
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
Any. Pick a working directory and have at it.
Reading through this thread should help. Basically pass the file name along with application source to
cobc.Umm, this is were your programming skills come in, there is a project space at
https://sourceforge.net/projects/dbpre
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.
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
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
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
OK, sent to him.
Thanks for reminding me - too busy programming to think straight :)
Vince
On 11/02/17 18:45, Brian Tiffin wrote: