First, Introduction
ODB is an open-source, cross-platform, cross-database object-relational mapping (ORM) system applied to C + +.
It allows you to persist C + + objects to relational databases without having to work with tables, columns, or SQL, without having to manually write any mapping code.
ODB supports mysql,sqlite,postgresql,oracle and Microsoft SQL Server relational databases as well as the C ++98/03 and C ++11 language standards.
It also comes with a configuration file for Boost and QT options, allowing you to seamlessly use these libraries to persist the value types, containers, and smart pointers of C + + classes.
It has the advantages of ease of use, concise code, security, database portability, excellent performance, maintainability and so on.
In short it has a very good C + + ORM Framework with perfect learning documentation.
can go to the official website to see more: http://www.codesynthesis.com/products/odb/
Second, the preparatory work
In the case of SQLite, on the Windows platform, use VS2013 to build the development environment.
1. Download the installation package
2, download ODB Core Library
3. Download the Database Runtime library
4, download the example program
5, download SQLite source files (with SQLite so need)
Address: http://www.codesynthesis.com/products/odb/download.xhtml
Because it is the Windows platform, the SQLite database uses the following files. (Other platforms, other databases download the corresponding library file)
Odb-2.3.0-i686-windows (oDB compiler, which is the object pair SQL and header file, used for persistence related)
libodb-2.3.0 (ODB Core Library, compiled odb_d.lib (debug version) required in examples)
libodb-sqlite-2.3.0 (ODB operation SQLite related functions, compiled odb-sqlite-d.lib (debug version) required in examples)
odb-examples-2.3.0 (examples and demos of ODB)
Three, install ODB
Installation is simple.
1, unzip the odb-2.3.0-i686-windows,
2. Add the bin directory to the environment variable
3, command line input ODB--version see if the installation is successful
Details can be read in the readme written.
As the following tips, you can say that the installation is successful
Four, compile ODB core library, ODB SQLite Library, SQLite Library
The following are the debug versions that are said.
1, compile ODB core library, generate Odb-d.lib and Odb-d-2.3-vc11.dll
2, compile SQLite library, generate Sqlite.lib
3, compile ODB's SQLite library, generate Odb-sqlite-d.lib and Odb-sqlite-d-2.3-vc11.dll
Decompression libodb-2.3.0, you will see the vs2008-2011 project files, really connect with vs open on OK, and then add the following path to the VC directory.
Include: ... \libodb
Library: ... \libodb\lib
Executable: ... \libodb\bin
Then compile, generate Odb-d.lib in the Lib directory and generate Odb-d-2.3-vc11.dll in the bin directory.
With SQLite compiled, generate Sqlite.lib, directly can refer to the official website.
Note that in the compilation of the need to add sqlite_enable_unlock_notify macro, if not added, it will be in the LIBODB-SQLITE-2.3.0 project to remove Libodb_sqlite_have_unlock_ Notify macros.
Unzip the libodb-sqlite-2.3.0 and also open the VS project file. Add the VC directory to the project.
Include: ... \libodb-sqlite
Library: ... \libodb-sqlite\lib
Executable: ... \libodb-sqlite\bin
To add the Odb-d.lib directory to the library, add Odb-d-2.3-vc11.dll to executable.
Also want to put SQLite's header file so in the directory in the include, the Sqlite.lib directory to add to the library.
Then compile, generate Odb-sqlite-d.lib in the Lib directory and generate Odb-sqlite-d-2.3-vc11.dll in the bin directory.
Five, run the example program
Pre-work has been done, direct decompression, with VS open.
My advanced is the Hello program.
1. Generate, Persion.hxx, and Person-odb.ixx files with the ODB compiler.
In this directory, enter odb-d sqlite--generate-query--generate-schema person.hxx
See: http://www.codesynthesis.com/products/odb/doc/odb.xhtml
2, the core library header files, libodb-sqlite header files and SQLite header file directory added to the VC's include.
3, the Sqlite.lib,odb-sqlite-d.lib,odb-d.lib directory is added to the VC libary.
Then compile and run. Appear
Demonstrate the success of the building.
Summarize:
1,odb is only contact, at that time go not detours, the reason is precipitant eager, do not read the document, under the package on the open, the results can be imagined. Do not build a plateau on a floating sand.
2, compile time for a mistake blindly Google for a long time, finally found that their output did not look, directly see the error panel went.
Episode: At that time ODB installed, in their own open cmd command odb is OK, but in batch write ODB system can not find ODB. Causes an error in the "vs" example. (vs has to call ODB to modify the relevant file), but the VS report is a connection error, Cmd.exe 9009 error. Without looking at the output, Google went directly. Later found to be unable to find ODB, half a day did not solve. It was later resolved after the re-start. Does the environment variable have a certain cache?
3, more look at the document, the operation of the official website is written in detail, and each package, there are readme and Insall documents, all on how to run a detailed description, according to the above is generally no problem. The project was well thought out and 2008 to 2011 of the projects were given.
ODB the basic Environment of learning notes