本文共 2739 字,大约阅读时间需要 9 分钟。
这篇博客应该是和之前的重拾cgi一起的。当时为了模仿java的web框架,从页面的模板,到数据库的ORM,都找个对应的库来进行尝试。数据库用的就是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 versionatorDESCRIPTION="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 versionatorDESCRIPTION="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_installrm -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