Installing ODB on Fedora and alike
This README
describes installing the ODB compiler
(odb
), runtime libraries (libodb
,
libodb-<database>
), and profile libraries
(libodb-boost
, libodb-qt
) from binary packages on
Fedora and alike (RHEL, etc).
The libodb-sqlite
, libodb-pgsql
, and
libodb-mysql
packages depend on the underlying database client
library packages which come from the distribution's official package
repository.
Note also that the libodb-boost
and libodb-qt
packages have no dependency on Boost/Qt. Instead, if you wish to use the
corresponding profile, you are expected to install the desired
packages/versions explicitly.
The following ODB binary packages are provided for Fedora and alike (here
<...>
denotes the version, distribution, and architecture
information, for example 2.5.0-1.fc41.x86_64
or
2.5.0-1.el9.x86_64
):
odb-<...>.rpm -- ODB compiler libodb-<...>.rpm -- Common runtime files libodb-devel-<...>.rpm -- Common runtime development files libodb-sqlite-<...>.rpm -- SQLite runtime files libodb-sqlite-devel-<...>.rpm -- SQLite runtime development files libodb-pgsql-<...>.rpm -- PostgreSQL runtime files libodb-pgsql-devel-<...>.rpm -- PostgreSQL runtime development files libodb-mysql-<...>.rpm -- MySQL runtime files libodb-mysql-devel-<...>.rpm -- MySQL runtime development files libodb-boost-<...>.rpm -- Boost profile files libodb-boost-devel-<...>.rpm -- Boost profile development files libodb-qt-<...>.rpm -- Qt profile files libodb-qt-devel-<...>.rpm -- Qt profile development files
Additionally, the following optional packages provide debug information for the above packages:
odb-debuginfo-<...>.rpm -- ODB compiler debug info libodb-debuginfo-<...>.rpm -- Common runtime debug info libodb-sqlite-debuginfo-<...>.rpm -- SQLite runtime debug info libodb-pgsql-debuginfo-<...>.rpm -- PostgreSQL runtime debug info libodb-mysql-debuginfo-<...>.rpm -- MySQL runtime debug info libodb-boost-debuginfo-<...>.rpm -- Boost profile debug info libodb-qt-debuginfo-<...>.rpm -- Qt profile debug info
Typically, when installing ODB, you would install the ODB compiler
(odb
), the common runtime library (libodb
), plus
one or more database-specific runtime libraries
(libodb-<database>
), depending on which database(s) you wish
to target. To be able to persist types from either Boost or Qt you would
also install the corresponding profile library.
Putting it all together, if, for example, you wish to use SQLite, run:
$ sudo dnf install odb-<...>.rpm \ libodb-<...>.rpm \ libodb-devel-<...>.rpm \ libodb-sqlite-<...>.rpm \ libodb-sqlite-devel-<...>.rpm
Or, as another example, if you wish to use PostgreSQL as well as the Boost profile, run:
$ sudo dnf install odb-<...>.rpm \ libodb-<...>.rpm \ libodb-devel-<...>.rpm \ libodb-pgsql-<...>.rpm \ libodb-pgsql-devel-<...>.rpm \ libodb-boost-<...>.rpm \ libodb-boost-devel-<...>.rpm \ boost-devel \ postgresql
Notice that here we are also installing Boost and the PostgreSQL client
program (psql
) from the distribution's package repository.
To test the installation you can try to build and run an example, for
example hello
from the odb-examples
source package (see examples README
for
details).
To build and run the example with SQLite, execute:
$ odb --std c++11 -d sqlite --generate-query --generate-schema \ person.hxx $ c++ -c person-odb.cxx $ c++ -DDATABASE_SQLITE -c driver.cxx $ c++ -o driver driver.o person-odb.o -lodb-sqlite -lodb -lsqlite3 $ ./driver --help $ ./driver --database ./test.sqlite3
To build and run the example with PostgreSQL, execute:
$ odb --std c++11 -d pgsql --generate-query --generate-schema \ person.hxx $ c++ -c person-odb.cxx $ c++ -DDATABASE_PGSQL -c driver.cxx $ c++ -o driver driver.o person-odb.o -lodb-pgsql -lodb $ psql --username=odb_test --dbname=odb_test -f person.sql $ ./driver --help $ ./driver --user odb_test --database odb_test