Just checked - the FAQ entry is a bit outdated (@btiffin: you may want to fix this and also get esqlEC listed either directly before or after ocesql instead of down in 7.22).
The current release is the version 1.2, do you use that?
Hm, if you add -static the error should go away, either you should see a link-time error (whhen executing cobc -x -static -locesql inserttbl.cob or everything should work.
So I guess you see the link-time error when doing cobc -x -static inserttbl.cob, don't you?
Note: instead of using static calls you could also switch to pre-loading the library:
COB_PRE_LOAD=libocsql COB_LIBRARY_PATH=/path/to/libocsql cobcrun --runtime-env (and you either see that the preload worked, or that it did not)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is the "esqlOC" version:
esqlOC
esqlOC: ESQL for GnuCOBOL/OpenCobol Version 2 (2019.02.26) Build Jul 18 2019
Usage: esqlOC [-Q][-F][-static][-I <copybook-directory> [| -I <copybook-directory>]</copybook-directory></copybook-directory>] [-o <output-file>]</output-file> <filename> ...
-Q Use double quotes
-F Force unknown SQL statements to be accepted as "execute immediate"
-static Use static calls to OCSQL library
===============================================================
and
COB_PRE_LOAD=libocsql
COB_LIBRARY_PATH=/usr/local/lib/libocsql cobcrun --runtime-env
cobc -x -static -locesql inserttbl.cob
configuration error:
default.conf: No such file or directory
=====================================================
I don't know what to do anymore, or am I too stupid.</filename>
Celso Henrique
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
See where cobc is looking. Merge the two views by perhaps manually moving files around, Celso. It's a sign that things are pretty mungled for the cobc in $PATH and the install that happened last. Hopefully seeing where cobc is looking can help figure out what might be causing the grief.
Cheers,
Blue
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The implicit declarations are strange, cobc should generate those on the fly.
What does cobc -Vsays?
The link errors for log10 and ceil are shown as dependecies of the libocesql library - adjust to: cobc -x -static -lm -locesql inserttbl.cob and it should work
The "missing module" is also clear to me now - there's simply no such module, either use static linking (also possible "per entry point" with multiple -K entryName, for all the entry points noted in "LIST OF CALLED DB Library API" summaries instead of the global "everything that is CALL 'literal' that you get with -static) together with -llibname as done above, or preload the library as noted above which will remove the need to specify a link library (and ease later updates: just pre-load another one, no re-link needed).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've tried everything, here, to solve this example, if you can give me the solution I'll thank you very much.
But what I don't understand is that I managed to solve another example, whose link is this: "https://sourceforge.net/p/open-cobol/contrib/HEAD/tree/trunk/samples/DBsample/PostgreSQL/". And it uses practically the same tools.
Celso Henrique.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear.
I tried with all versions of GNUcobol, but these current results are with the version "cobc (GnuCOBOL) 3.1-rc1.0".
The most intriguing of all is that with the other example "https://sourceforge.net/p/open-cobol/contrib/HEAD/tree/trunk/samples/DBsample/PostgreSQL/"; I did all the examples and they worked correctly without errors. The only difference is the number of libraries added to the program. The database is the same "Postgres". I've honestly tried everything to find out, where I'm going wrong.
Celso Henrique.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
At least the programs work, now it must be a database connection problem, right.
Celso henrique.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2024-06-04
Hi @celsofigueiredo, since I don't see the final result in this thread, maybe you don't need it anymore but I'm putting here my solution after gone through various answers in this thread and others. Hope someone else get away difficulties.
The error above is related postgresql connection string standard, you have to:
First, create password for entry user (in this case, postgres):
Helping non-native speakers to understand the messages from both cobc and the programs it calls by specifying via LANG=EN that all messages should be returned in English. This has nothing to do with any result (other than the language used to find the message-catalogs).
Specify via --verbose that cobc will output what it does, this is something that often helps to "debug" some things related to that.
Specify via --static that all CALL "literal" should be directly resolved, internally this leads to a C function call with that name - if the linker cannot resolve that it will output an error.
Specify an additional library. libocesql uses math functions that are not part of the compiler in your specific setup. The linker "sees" those and can not resolve them, leading to error messages. When looking at the manpages for those functions or "on the internet" one can see where to find them, which is libmath in this case. As many systems resolve the dependencies in order (in most cases also removing "unneeded" entries (optimization and security) = those that were not referenced before) - from left to right - it is important to use the correct order (which is the reason that it does not work when specified different - in your case, on other machines it doesn't matter [and also wouldn't matter if the linker was told to not remove these additional entry points]).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear.
Thanks for your help, I'm almost done with this program, but I just remembered that I didn't do a process at the beginning of the compilation:
5. Installation===============
To install Ocesql:
./configure
make
make install
For use with PostgreSQL 9.0 or later:
export CPPFLAGS="-I/usr/pgsql-9.x/include" # -->1
export LDFLAGS="-L/usr/pgsql-9.x/lib" # -->2
./configure
make
make install
I am using postgres 9.5 and in place of that item (2) export LDFLAGS="-L/usr/pgsql-9.x/lib"; I put the following, which corresponds to where the postgres is: export LDFLAGS="-L/usr/lib/postgresql/9.5/lib"; already the item (1), I could not find the folder" include ". The error must be at this point: export CPPFLAGS="-I/usr/pgsql-9.x/include".
And as you already know, I am very bad at configuring.
In this CPPFLAGS variable, do I have to configure how?
Celso Henrique.
Last edit: Simon Sobisch 2020-07-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
-- using OCESQL 1.2 (correct?), yes it is correct
-- using postgresql 9.5 (installed as?), like using ubuntu, postgres comes in the package, installed through the synaptic package manager.
Explain me better (In any case I'd suggest to not export those variables but specify them during configure ).
I do not really understand this question of variables, where it is better to specify them.
What is the best place to specify these variables:
CPPFLAGS
LDFLAGS
and the other GNUcobol variables, postgres, mysql and other auxiliary programs.
Celso Henrique.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I redid this example again, from the beginning, but it continues to fail, this time I complained about the lack of lib "libocesql.so.0"; but this lib exists and is in the "usr / local / lib" directory. I ask again, what am I doing WRONG?
Dear friends,
Following the example of this link: https://gnucobol.sourceforge.io/faq/gcfaq.html#index-917 , I managed to get to this point:
Where am I going wrong.
Celso Henrique
Last edit: celsofigueiredo 2020-07-21
Does it change if you add -static to the compile command? Just a wild guess ..
Dear.
I did the test again, but using the -static option, and kept giving the same error. Where am I going wrong?
Celso Henriqe
Just checked - the FAQ entry is a bit outdated (@btiffin: you may want to fix this and also get esqlEC listed either directly before or after ocesql instead of down in 7.22).
The current release is the version 1.2, do you use that?
Hm, if you add
-staticthe error should go away, either you should see a link-time error (whhen executingcobc -x -static -locesql inserttbl.cobor everything should work.So I guess you see the link-time error when doing
cobc -x -static inserttbl.cob, don't you?Note: instead of using static calls you could also switch to pre-loading the library:
COB_PRE_LOAD=libocsql COB_LIBRARY_PATH=/path/to/libocsql cobcrun --runtime-env(and you either see that the preload worked, or that it did not)Dear.
This is the "esqlOC" version:
esqlOC
esqlOC: ESQL for GnuCOBOL/OpenCobol Version 2 (2019.02.26) Build Jul 18 2019
Usage: esqlOC [-Q] [-F] [-static] [-I <copybook-directory> [| -I <copybook-directory>]</copybook-directory></copybook-directory>] [-o <output-file>]</output-file> <filename> ...
-Q Use double quotes
-F Force unknown SQL statements to be accepted as "execute immediate"
-static Use static calls to OCSQL library
===============================================================
and
COB_PRE_LOAD=libocsql
COB_LIBRARY_PATH=/usr/local/lib/libocsql cobcrun --runtime-env
cobc -x -static -locesql inserttbl.cob
configuration error:
default.conf: No such file or directory
=====================================================
I don't know what to do anymore, or am I too stupid.</filename>
Celso Henrique
Nope, just in a swamp of details.
You need to find default.conf, and make sure overwrite installs aren't getting cross wired or confusing things.
See how many copies might be on system,
See where cobc is looking. Merge the two views by perhaps manually moving files around, Celso. It's a sign that things are pretty mungled for the
cobcin$PATHand the install that happened last. Hopefully seeing where cobc is looking can help figure out what might be causing the grief.Cheers,
Blue
cobc --info will tell you where it looks for and gives a hint what environment variable you may tweak to point it to the correct config directory.
Dear.
After some adjustments and corrections, I managed to get to this point, using the
-staticoption:Without that
-staticoption the program compiles, but the following appears:celso @ celso-Aspire-4740: ~ / Cobol $
I really don't know what I'm doing wrong.
Last edit: Simon Sobisch 2020-07-08
The implicit declarations are strange,
cobcshould generate those on the fly.What does
cobc -Vsays?The link errors for log10 and ceil are shown as dependecies of the libocesql library - adjust to:
cobc -x -static -lm -locesql inserttbl.coband it should workThe "missing module" is also clear to me now - there's simply no such module, either use static linking (also possible "per entry point" with multiple
-K entryName, for all the entry points noted in "LIST OF CALLED DB Library API" summaries instead of the global "everything that isCALL 'literal'that you get with-static) together with-llibnameas done above, or preload the library as noted above which will remove the need to specify a link library (and ease later updates: just pre-load another one, no re-link needed).Dear.
I've tried everything, here, to solve this example, if you can give me the solution I'll thank you very much.
But what I don't understand is that I managed to solve another example, whose link is this: "https://sourceforge.net/p/open-cobol/contrib/HEAD/tree/trunk/samples/DBsample/PostgreSQL/". And it uses practically the same tools.
Celso Henrique.
Isn't
cobc -x -static -lm -locesql inserttbl.cobthe solution (what GC-version do you use in this setup btw)?Ceslo, one part of "everything" you didn't try was answering Simon's question:
It seems your compiler is not behaving normally. The version information might explain why not.
Dear.
I tried with all versions of GNUcobol, but these current results are with the version "cobc (GnuCOBOL) 3.1-rc1.0".
The most intriguing of all is that with the other example "https://sourceforge.net/p/open-cobol/contrib/HEAD/tree/trunk/samples/DBsample/PostgreSQL/"; I did all the examples and they worked correctly without errors. The only difference is the number of libraries added to the program. The database is the same "Postgres". I've honestly tried everything to find out, where I'm going wrong.
Celso Henrique.
We totally believe you that you've did this.
Two questions:
LANG=EN cobc -x -static --verbose -lm -locesql inserttbl.cob(if that doesn't work then without theLANG=EN)?Dear, Simon Sobisch.
I am testing this example in a Linux Ubuntu 16.04 64-bit environment and the result you requested gave the following result:
What am I doing wrong?
Celso Henrique
looks correct. Any change with
LANG=EN cobc -x -static --verbose -locesql -lm inserttbl.cob?Dear,
With this format, it gave:
Celso henrique
Dear.
And the results of the two programs were:
At least the programs work, now it must be a database connection problem, right.
Celso henrique.
Hi @celsofigueiredo, since I don't see the final result in this thread, maybe you don't need it anymore but I'm putting here my solution after gone through various answers in this thread and others. Hope someone else get away difficulties.
The error above is related postgresql connection string standard, you have to:
$sudo -u postgres -i psqlpostgres=# \passwordHope you doing well,
Manh
Last edit: Simon Sobisch 2024-06-04
Dear
What is the difference between these two ways of running "cobc":
celso@celso-Aspire-4740:~/Cobol$ export COBCPY=/home/celso/Cobol/copy
celso@celso-Aspire-4740:~/Cobol$ LANG=EN cobc -x -static --verbose -locesql -lm inserttbl.cob
and
celso@celso-Aspire-4740:~/Cobol$ export COBCPY=/home/celso/Cobol/copy
celso@celso-Aspire-4740:~/Cobol$ cobc -x -locesql inserttbl.cob
Celso Henrique.
There are 4 big differences in those ways:
Helping non-native speakers to understand the messages from both cobc and the programs it calls by specifying via
LANG=ENthat all messages should be returned in English. This has nothing to do with any result (other than the language used to find the message-catalogs).Specify via
--verbosethatcobcwill output what it does, this is something that often helps to "debug" some things related to that.Specify via
--staticthat allCALL "literal"should be directly resolved, internally this leads to a C function call with that name - if the linker cannot resolve that it will output an error.Specify an additional library. libocesql uses math functions that are not part of the compiler in your specific setup. The linker "sees" those and can not resolve them, leading to error messages. When looking at the manpages for those functions or "on the internet" one can see where to find them, which is libmath in this case. As many systems resolve the dependencies in order (in most cases also removing "unneeded" entries (optimization and security) = those that were not referenced before) - from left to right - it is important to use the correct order (which is the reason that it does not work when specified different - in your case, on other machines it doesn't matter [and also wouldn't matter if the linker was told to not remove these additional entry points]).
Dear.
Thanks for your help, I'm almost done with this program, but I just remembered that I didn't do a process at the beginning of the compilation:
I am using postgres 9.5 and in place of that item (2)
export LDFLAGS="-L/usr/pgsql-9.x/lib"; I put the following, which corresponds to where the postgres is:export LDFLAGS="-L/usr/lib/postgresql/9.5/lib"; already the item (1), I could not find the folder" include ". The error must be at this point:export CPPFLAGS="-I/usr/pgsql-9.x/include".And as you already know, I am very bad at configuring.
In this
CPPFLAGSvariable, do I have to configure how?Celso Henrique.
Last edit: Simon Sobisch 2020-07-18
It all depends on where your include files (= sql headers) are. and this also depends how you've installed postgresql.
I'm also a bit confused as you've previously mentioned esqlOC version 2.0 and also reference OCESQL. The first one is hosted at https://sourceforge.net/p/open-cobol/contrib/HEAD/tree/trunk/esql and works via ODBC, the second is hosted at https://github.com/opensourcecobol/Open-COBOL-ESQL/releases (at version 1.2) and uses direct link to postgresql.
Please help me summarize:
In any case I'd suggest to not export those variables but specify them during configure (this should work and be more self-contained).
Dear Simon,
-- using OCESQL 1.2 (correct?), yes it is correct
-- using postgresql 9.5 (installed as?), like using ubuntu, postgres comes in the package, installed through the synaptic package manager.
Explain me better (In any case I'd suggest to not export those variables but specify them during configure ).
I do not really understand this question of variables, where it is better to specify them.
What is the best place to specify these variables:
CPPFLAGS
LDFLAGS
and the other GNUcobol variables, postgres, mysql and other auxiliary programs.
Celso Henrique.
Dear.
I redid this example again, from the beginning, but it continues to fail, this time I complained about the lack of lib "libocesql.so.0"; but this lib exists and is in the "usr / local / lib" directory. I ask again, what am I doing WRONG?
Celso Henrique.