ODB——基于c++的ORM映射框架尝试(安装)
這篇博客應該是和之前的重拾cgi一起的。當時為了模仿java的web框架,從頁面的模板,到數據庫的ORM,都找個對應的庫來進行嘗試。數據庫用的就是ODB,官方網站是http://www.codesynthesis.com/products/odb/。
1、安裝
odb是直接提供源代碼的,主要包含這幾個部分:odb、libodb、libodb-sqlite等,用途分別是:
odb是ODB編譯器,類似于qt的moc,將c++源碼中包含ODB特定宏的代碼,生成對應的c++代碼。
libodb是運行時庫,ORM映射的主要邏輯都在這里
libodb-sqlite等,是odb提供的針對不通數據庫的驅動,以實現對數據庫的底層操作。其他還有profile、example等包,沒有用到就沒去了解。
這些包都是很標準的源碼包,通過configure、make等就可以進行安裝了。給自己的gentoo系統,針對這些用到的包寫了ebuild。
[cce]
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4
inherit eutils autotools-utils versionator
DESCRIPTION="ODB Compiler"
HOMEPAGE="http://www.codesynthesis.com/products/odb/"
SRC_URI="http://www.codesynthesis.com/download/${PN}/$(get_version_component_range 1-2)/${P}.tar.bz2"
LICENSE="GPLv2"
SLOT="0"
KEYWORDS="~amd64"
IUSE=""
DEPEND="dev-cpp/libcutl"
RDEPEND="${DEPEND}"
src_prepare() {
epatch "${FILESDIR}/${PN}-distdir.patch"
}
[/cce]
這里要注意下,odb編譯依賴libcutl,這個貌似也是這個codesynthesis上的,對此也寫了一個ebuild:
[cce]
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4
inherit autotools-utils versionator
DESCRIPTION="Library of C++ utilities — meta-programming tests, smart pointers,
containers"
HOMEPAGE="http://codesynthesis.com/projects/libcutl/"
SRC_URI="http://codesynthesis.com/download/${PN}/$(get_version_component_range 1-2)/${P}.tar.bz2"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~mips"
IUSE="static-libs"
DEPEND="dev-libs/boost"
RDEPEND="${DEPEND}"
src_configure() {
local myeconfargs=(
–with-external-boost
–docdir=/tmp/dropme
)
autotools-utils_src_configure
}
src_install() {
autotools-utils_src_install
rm -r "${D}"/tmp/dropme || die
}
[/cce]
libodb的ebuild:
[cce]
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4
DESCRIPTION="ODB is an open-source, cross-platform and cross-database
object-relational mapping (ORM) system for C++."
HOMEPAGE="http://www.codesynthesis.com/products/odb/"
SRC_URI="http://www.codesynthesis.com/download/odb/2.0/${P}.tar.bz2"
LICENSE="GPLv2"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~mips"
IUSE=""
DEPEND="dev-db/odb"
RDEPEND="${DEPEND}"
[/cce]
libodb-sqlite的ebuild:
[cce]
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4
DESCRIPTION=”ODB is an open-source, cross-platform and cross-database
object-relational mapping (ORM) system for C++.”
HOMEPAGE=”http://www.codesynthesis.com/products/odb/”
SRC_URI=”http://www.codesynthesis.com/download/odb/2.0/${P}.tar.bz2″
LICENSE=”GPLv2″
SLOT=”0″
KEYWORDS=”~amd64 ~x86 ~mips”
IUSE=””
DEPEND=”dev-db/libodb
dev-db/sqlite”
RDEPEND=”${DEPEND}”
[/cce]
轉載自:https://coolex.info/blog/374.html
總結
以上是生活随笔為你收集整理的ODB——基于c++的ORM映射框架尝试(安装)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 1、单例模式
- 下一篇: 我看objective-C --不要把o