Introduction
Installation on MinGW/MinGW64 follows the general steps outlined in Installing ODB on Linux/UNIX. This guide presents additional information for this platform and should be read first.
Installing the ODB Compiler
To install the ODB compiler, use the pre-compiled binary package for Windows as outlined in Installing ODB on Windows.
The ODB compiler package for Windows includes a private copy of
minimal MinGW64/MSYS environment in the mingw/
subdirectory
(you can start the terminal by running mingw/msys.bat
).
You are not expected to use this environment to build the
ODB runtimes. Instead, you should use the same environment (that is,
GCC compiler, headers, etc.) that you use to build your application.
However, it can be used as a reference since we have successfully
built and run all the tests and examples for all the databases using
this minimal environment.
Installing the Runtime Libraries
The building and installation of the ODB runtime libraries follow
the general UNIX steps mentioned above. Make sure you use the same
GCC and the same options (e.g., -m32
/-m64
)
as when building your application. When testing ODB on MinGW64
using the above-mentioned minimal environment, the only extra
configure
option that is passed is
-Wl,--enable-auto-import
in LDFLAGS
.
One challenging aspect of building the ODB runtimes is to get the
underlying database client libraries to work with MinGW. Normally,
those come with the DLL and the import library (.lib
)
that were built with VC++. With some version of MinGW/MinGW64,
simply renaming the library from .lib
to .a
is all that is necessary. Newer versions,
however, will complain that the resulting library format is
invalid (see the config.log
for details).
If the renaming approach does not work, then the next step is to
try to generate a new import library using the gendef
and dlltool
utilities (if your MinGW environment
does not have them, then you can try the ones that come with the
ODB compiler in mingw/bin/
). Here is an example
for PostgreSQL's libpq
:
gendef.exe libpq.dll dlltool.exe -D libpq.dll -d libpq.def -l libpq.a
While this is usually all that is necessary, sometimes the resulting
library doesn't quite work. Common symptoms include unresolved
symbols during linking of the ODB runtime or when loading the
application that links to it. If that happens, then the next approach
to try is to use the reimp
tool (also comes
with the ODB compiler). Here is an example for MySQL's
libmysql
:
reimp libmysql.lib mv liblibmysql.a libmysqlclient_r.a