mridoni / gixsql

GixSQL is an ESQL preprocessor and a series of runtime libraries to enable GnuCOBOL to access PostgreSQL, ODBC, MySQL, Oracle and SQLite databases.
GNU General Public License v3.0
13 stars 6 forks source link

Unable to link in TSQL001A in MinGW (Windows 11) using gixsql ver 1.0.20b #186

Open domninguem opened 3 months ago

domninguem commented 3 months ago

Trying to follow the example in the README file to link TSQL001A.cbsql after having successfully executed the preprocesser using gixpp. In a Windows 11 platform, version of the GnuCOBOL compiler (3.2.0) shown below.

This is my first time trying to use Gixsql (ver 1.0.20b) (did I say "first time"?). I installed Postgres (16.3) and then installed Gixsql using gixsql-binaries-windows-x64-mingw-1.0.20b-1.7z.sig.

Here's the cobc command line arguments (executed in VS Code terminal mode):

C:\gnucobol>cobc -x TSQL001A.cbsql -L"c:\program files\gixsql\lib\x64\gcc" -lgixsql

Output from running cobc -V cobc (GnuCOBOL) 3.2.0 Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart Built Jul 28 2023 16:08:08 Packaged Jul 28 2023 16:58:47 UTC C version (MinGW) "13.1.0"

Terminal flooded with undefined references such as the following:

C:\gnucobol\bin/ld.exe: c:/program files/gixsql/lib/x64/gcc/libgixsql.a(libgixsql_la-gixsql.o):(.text+0x62a3): undefined reference to `std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_construct(unsigned long long, char)'

I can find the references in libgixsql.a that is in the supplied directory (.../lib/x64/gcc). So I think it's just not finding the library?

GitMensch commented 3 months ago

Welcome @domninguem to GixSQL, GitHub and possibly to GnuCOBOL!

It seems that the static library uses C++ functions (expected for gixsql) while the linker does not know those have to be included. I'd try to add -lstdc++ (or -lstdc++-6) first when invoking cobc. If you get different undefined references afterwards we may need to add more libraries.

domninguem commented 3 months ago

Thanks for the response. I tried executing COBC with the parm -lstdc++ but got the same result. I looked in c:\gnucobol\lib but only found these libraries with prefix libstdc++ (see below). I do see libstdcc-6.a in some other apps' lib folder but am reluctant to copy to gnucobol\lib.

Is this part of a larger issue? Should I have downloaded the MSVC version vs MinGW for GnuCOBOL?

image

GitMensch commented 3 months ago

That should work fine, hopefully @mridoni finds the time to answer.

In any case using the same environment (MinGW32 or 64 MSYS2 based one vs. "good old" mingw vs MSVC with a matching version) for GnuCOBOL and GixSQL will help a lot.

domninguem commented 3 months ago

I added -lstdc--6 and another library path for it. This time around it looks like all the undefined references are tied to fmt::v9:: -- see snippet below.

C:\gnucobol>cobc -x TSQL001A.cbsql -lstdc++ -lstdc++-6 -L "C:\Program Files\GixSQL\lib\x64\gcc" -L "c:\program files\GixSQL\bin" -lgixsql

image