[odb-users] Question concerning cross compiling ODB
boris at codesynthesis.com
Mon May 20 10:42:16 EDT 2013
Michael Powell <mwpowellhtx at gmail.com> writes:
> We've got an app that is cross compiled for Linux ARM architecture. If
> I understand properly, ODB hooks into the GCC in order to facilitate
> the code generation from the #pragmas embedded in the object model.
Yes, this is correct. Note however, that the ODB compilation is a
separate step and it doesn't have to use the same GCC (or, more
generally, the same C++ compiler) as the one you use to build your
> We've got GCC 4.7.2 cross compilers for ARM, I use a toolchain from
> launchpad.net for "headless" (non-IDE) building, and the Sourcery
> CodeBench toolchain for IDE-enriched development.
> Possible to use ODB for this purpose?
> What sort of cross compile support is there out of the box if, say,
> we download the sources, configure, make, and build it? How to hook
> it in with GCC?
The easiest way would be to use one of the pre-built ODB compiler
binaries that include a private copy of GCC (happens to also be 4.7.2).
We have a very detailed guide on how to cross-compile and use ODB for
the Raspberry Pi target (which also happens to be ARM/Linux).
> May also have some observations about how to abstract transactions
> away from common ORM code as a "unit of work" design pattern, perhaps
> using C++ templates: i.e. template<class UnitOfWork> type thing, with
> common operations being begin, commit, rollback, type thing.
I am not sure I understand what you are asking here. In ODB you don't
need to have a reference to transaction in order to perform a database
operation. Which means you can write code that just calls, say, load(),
as long as you know that it will be called within a transaction. In other
// Has to be called within a transaction.
void nested (odb::database& db)
shared_ptr<object> o (db.load<object> (id));
transaction t (db.begin ());
More information about the odb-users