[odb-users] How to compile "hello" example on RHEL

Boris Kolpackov boris at codesynthesis.com
Sun Sep 9 05:52:07 EDT 2012


Hi Sean,

Stroud, Sean T <ststrou at sandia.gov> writes:

> Only one problem – how do you compile them? For the “hello” example
> I see there is a “README” file. I would expect the README file to
> say how to compile and link the example but it doesn’t (it only
> tells how to run odb to generate the code).

The problems with giving such instructions in README is that they are
very platform-specific (i.e., on Linux one could use configure & make
while on Windows with VC++ one would use solution files). And these
are described in the INSTALL file in the root of the odb-examples
package.

But I agree, perhaps we should also include some information on how
to build each example manually, from the command line. I've added
this item to the TODO list.

> % g++ -c driver.cxx -I /home/ststrou/ODB/libodb-1.7.0 -I \
> /home/ststrou/ODB/libodb-mysql-1.7.0
> 
> But that fails with the following output:
> 
> [...]
>
> /home/ststrou/ODB/libodb-1.7.0/odb/details/config.hxx:17:34: error: odb/details/config.h: No such file or directory

I don't think you have built libodb and libodb-mysql (i.e., by running
configure and then make). For a high-level overview of how to do this,
see the "Installing ODB on UNIX" page:

http://www.codesynthesis.com/products/odb/doc/install-unix.xhtml

For more detailed information refer to the INSTALL file in each package.

You can just build libodb and libodb-mysql without installing them and
the above command will work. However, things will get progressively
more complicated from there. Specifically, the linking step will require
you to find and specify .so files. Running the example will fail unless
you add the paths where these libraries are located to LD_LIBRARY_PATH.

Instead, it is much easier to install the headers and the libraries to
the location where g++ will search for them automatically (/usr/local
by default).

Normally, to build and install these libraries all you have to do is run
these commands in each directory:

./configure
make
sudo make install

If later you want to uninstall them, then just run:

sudo make uninstall

Ok, assuming that you have libodb and libodb-mysql installed, the command
line to compile and link the hello example will then look like this:

g++ -DDATABASE_MYSQL -c driver.cxx person-odb.cxx
g++ -o driver driver.o person-odb.o -lodb-mysql -lodb

Note the DATABASE_MYSQL define -- it selects which database the example
should target.

Boris



More information about the odb-users mailing list