openwrt 移植sqlite3

前端之家收集整理的这篇文章主要介绍了openwrt 移植sqlite3前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

openwrt sqlite3移植

一、配置支持数据库

1、在工程源码下执行make menuconfig 在界面里面选上数据库支持

Utilities----->

database------>

sqlite2-cli............ sqlite (v2.x)database engine (cli)

二、修改数据库版本

1、Openwrt 支持的数据版本是sqlite2的,sqlite2的接口和sqlite3接口差别很大

2、修改支持sqlite3,vim Feeds/packages/libs/sqlite2/Makefile

将版本号修改sqlite3和编译之后拷贝的库的名字

PKG_NAME:=sqlite3

PKG_VERSION:=3.6.17

PKG_RELEASE:=3

详细的脚本请参考(注:直接拷贝脚本进去编译有可能会出现语法错误

include $(TOPDIR)/rules.mk

PKG_NAME:=sqlite3

PKG_VERSION:=3.6.17

PKG_RELEASE:=3

PKG_SOURCE:=sqlite-$(PKG_VERSION).tar.gz

PKG_SOURCE_URL:=http://www.sqlite.org/

PKG_MD5SUM:=838dbac20b56d2c4292e98848505a05b

PKG_BUILD_DIR:=$(BUILD_DIR)/sqlite-$(PKG_VERSION)

PKG_BUILD_DEPENDS:=libncurses libreadline

PKG_FIXUP:=autoreconf

PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk

TARGET_CFLAGS += $(FPIC)

define Package/sqlite2/Default

SUBMENU:=database

TITLE:=sqlite (v2.x) database engine

URL:=http://www.sqlite.org/

endef

define Package/libsqlite2

$(call Package/sqlite2/Default)

SECTION:=libs

CATEGORY:=Libraries

TITLE+= (library)

endef

define Package/libsqlite2/description

sqlite is a small C library that implements a self-contained,embeddable,

zero-configuration sql database engine.

This package contains the sqlite (v2.x) shared library,used by otherprograms.

endef

define Package/sqlite2-cli

$(call Package/sqlite2/Default)

SECTION:=utils

CATEGORY:=Utilities

DEPENDS:=+libncurses +libreadline +libpthread

TITLE+= (cli)

SUBMENU:=database

endef

define Package/sqlite2-cli/description

sqlite is a small C library that implements a self-contained,

zero-configuration sql database engine.

This package contains a terminal-based front-end to the sqlite (v2.x)library

that can evaluate queries interactively and display the results in

multiple formats.

endef

define Build/Configure

$(call Build/Configure/Default,\

--enable-shared \

--enable-static \

,\

config_BUILD_CC="$(HOSTCC)"\

config_BUILD_CFLAGS="-O2" \

config_TARGET_CC="$(TARGET_CC)" \

config_TARGET_CFLAGS="$(TARGET_CFLAGS)" \

config_TARGET_READLINE_INC="$(TARGET_CPPFLAGS)" \

config_TARGET_READLINE_LIBS="$(TARGET_LDFLAGS)-lreadline -lncurses" \

config_TARGET_TCL_INC="-DNO_TCL=1" \

)

endef

define Build/InstallDev

$(INSTALL_DIR) $(1)/usr/include

$(CP) $(PKG_INSTALL_DIR)/usr/include/sqlite3.h $(1)/usr/include/

$(INSTALL_DIR) $(1)/usr/lib

$(CP) $(PKG_INSTALL_DIR)/usr/lib/libsqlite3.{a,so*} $(1)/usr/lib/

$(INSTALL_DIR) $(1)/usr/lib/pkgconfig

$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/sqlite3.pc $(1)/usr/lib/pkgconfig/

endef

define Package/libsqlite2/install

$(INSTALL_DIR) $(1)/usr/lib

$(CP) $(PKG_INSTALL_DIR)/usr/lib/libsqlite3.so.* $(1)/usr/lib/

endef

define Package/sqlite2-cli/install

$(INSTALL_DIR) $(1)/usr/bin

endef

#$(CP) $(PKG_INSTALL_DIR)/usr/lib/libsqlite3.so.*$(1)/usr/lib/

#$(INSTALL_BIN)$(PKG_INSTALL_DIR)/usr/bin/sqlite $(1)/usr/bin/

$(eval $(call BuildPackage,libsqlite2))

$(eval $(call BuildPackage,sqlite2-cli))

三、库依赖关系

1、由于sqlite3需要用到线程库,直接编译会出现如下错误

missing dependencies libpthread.so.0

2、需要添加依赖线程库,在Makfile里面的DEPENDS添加libpthread 的支持

define Package/sqlite2-cli

$(call Package/sqlite2/Default)

SECTION:=utils

CATEGORY:=Utilities

DEPENDS:=+libncurses +libreadline +libpthread

TITLE+= (cli)

SUBMENU:=database

endef

3、再次编译,如果还出现错误,说面当前openwrt系统没有编译libpthread进去,需要到执行make menuconfig 配置支持

Basesystem ------->

<*>libthread……………………POSIX thread library

原文链接:https://www.f2er.com/sqlite/199898.html

猜你在找的Sqlite相关文章