OpenWrt Forum Archive

Topic: Link sqlite

The content of this topic has been archived on 24 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello
I have an application that works fine in Ubuntu and I know it has been compiled for cris os on foxboard before. Now i have made some changes and have added Sqlite to this application. It compiles fine in eclipse with dynamic linking to sqlite. Sqlite do compile fine in openwrt when i dont compile it at the same time as my app. But when i try to compile my app with openwrt to the foxboard it gives me errors like:

Logger.cpp:12:21: error: sqlite3.h: No such file or directory
Logger.cpp: In member function 'void Logger::runLogger()':
Logger.cpp:131: error: 'SQLITE_OPEN_READWRITE' was not declared in this scope

and

/home/lars/WRT/kamikaze/staging_dir/toolchain-cris_gcc-4.3.3_uClibc-0.9.30.1/usr/lib/gcc/cris-openwrt-linux-uclibc/4.3.3/../../../../cris-openwrt-linux-uclibc/include/c++/4.3.3/backward/backward_warning.h:33:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
Settings.cpp:17:21: error: sqlite3.h: No such file or directory
Settings.cpp: In member function 'void Settings::readConfigFile()':
Settings.cpp:91: warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime
Settings.cpp: In member function 'void Settings::readSettingsTable()':
Settings.cpp:214: error: 'SQLITE_OPEN_READONLY' was not declared in this scope
Settings.cpp:214: error: 'sqlite3_open_v2' was not declared in this scope

The makefile i am using for my app looks like:

include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_NAME:=DAIM
PKG_VERSION:=1
PKG_RELEASE:=1

# This specifies the directory where we're going to build the program.
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
# directory in your OpenWrt SDK directory 

PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

PKG_BUILD_DEPENDS:=sqlite3

# Specify package information for this program.
# The variables defined here should be self explanatory.

define Package/DAIM
    SECTION:=utils
    CATEGORY:=Utilities
    TITLE:=DAIM
    DEPENDS:=+sqlite3
endef

define Package/DAIM/description
    DAIM is a Data Aquisition I.. Module
endef


# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default. The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.

define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

# Specify where and how to install the program. Since we only have one file,
# the DAIM executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
# directory if it does not already exist. Likewise $(INSTALL_BIN) contains the
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.

define Build/Compile
    $(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS) CFLAGS="$(TARGET_CFLAGS)"
endef


define Package/DAIM/install
    $(INSTALL_DIR) $(1)/usr/local/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/DAIM $(1)/usr/local/bin/
    $(INSTALL_DIR) $(1)/etc/DAIM
    $(INSTALL_DATA) ./conf.dist/config.xml.dist $(1)/etc/DAIM/
    $(INSTALL_DIR) $(1)/etc/config/DAIM
    $(INSTALL_DATA) ./conf.dist/data.xml.dist $(1)/etc/DAIM/
    $(INSTALL_DIR) $(1)/var/run/DAIM
endef

# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.

$(eval $(call BuildPackage,DAIM))

the makefile used to sqlite:

 
# 
# Copyright (C) 2006-2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=sqlite
PKG_VERSION:=3.6.22
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-amalgamation-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.sqlite.org/


PKG_BUILD_DEPENDS:=libncurses libreadline

include $(INCLUDE_DIR)/package.mk

define Package/sqlite3/Default
  SUBMENU:=database
  TITLE:=SQLite (v3.x) database engine
  URL:=http://www.sqlite.org/
endef

define Package/sqlite3/Default/description
 SQLite is a small C library that implements a self-contained, embeddable,
 zero-configuration SQL database engine.
endef

define Package/libsqlite3
  $(call Package/sqlite3/Default)
  SECTION:=libs
  CATEGORY:=Libraries
  DEPENDS:=+libpthread
  TITLE+= (library)
endef

define Package/libsqlite3/description
$(call Package/sqlite3/Default/description)
 This package contains the SQLite (v3.x) shared library, used by other
 programs.
endef

define Package/sqlite3-cli
  $(call Package/sqlite3/Default)
  SECTION:=utils
  CATEGORY:=Utilities
  DEPENDS:=+libsqlite3 +libncurses +libreadline
  TITLE+= (cli)
endef

define Package/sqlite3-cli/description
$(call Package/sqlite3/Default/description)
 This package contains a terminal-based front-end to the SQLite (v3.x) library
 that can evaluate queries interactively and display the results in multiple
 formats.
endef

TARGET_CFLAGS += $(FPIC)

CONFIGURE_ARGS += \
    --enable-shared \
    --enable-static \

CONFIGURE_VARS += \
    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" \

define Build/Compile
    $(MAKE) -C $(PKG_BUILD_DIR) \
        DESTDIR="$(PKG_INSTALL_DIR)" \
        all install
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/libsqlite3/install
    $(INSTALL_DIR) $(1)/usr/lib
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsqlite3.so.* $(1)/usr/lib/
endef

define Package/sqlite3-cli/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/sqlite3 $(1)/usr/bin/
endef

$(eval $(call BuildPackage,libsqlite3))
$(eval $(call BuildPackage,sqlite3-cli))

I am very greatfull for any tips.

If there is a --with-sqlite configure option, you will need to add it to CONFIGURE_ARGS variable, i.e.  --with-sqlite="$(STAGING_DIR)/usr", to the OpenWRT Makefile for your software package so that the compilation process will be able to insert the proper directory to locate the sqlite header files. Otherwise, you probably need to add/modify the config_BUILD_CFLAGS="-O2 $(STAGING_DIR)/usr" \ (I am guessing here).

Please do let's know if this will do the trick.

Thanks for the tips. I will try it soon, just check the mail and intake some coffee first.

Now i have tried but with no success.

CONFIGURE_ARGS += \
    --with_sqlite="$(STAGING_DIR)/usr/include" \

CONFIGURE_VARS += \
    config_BUILD_CFLAGS="-02 $(STAGING_DIR)/usr" \

I think its a bit strange becouse it looks for me that it looks in the right places. This is a bit of the output just after it have compiled sqlite and just before the first errors/warnigs from my app.

WRToutput wrote:

make[3]: Entering directory `/home/lars/WRT/kamikaze/package/daim'
mkdir -p /home/lars/WRT/kamikaze/build_dir/target-cris_uClibc-0.9.30.1/DAIM
cp -fpR ./src/* /home/lars/WRT/kamikaze/build_dir/target-cris_uClibc-0.9.30.1/DAIM/
touch /home/lars/WRT/kamikaze/build_dir/target-cris_uClibc-0.9.30.1/DAIM/.prepared_28a70e3ae651baee5f6ff36df470a31c
(cd /home/lars/WRT/kamikaze/build_dir/target-cris_uClibc-0.9.30.1/DAIM/./; if [ -x ./configure ]; then /usr/bin/find /home/lars/WRT/kamikaze/build_dir/target-cris_uClibc-0.9.30.1/DAIM/ -name config.guess | xargs -r chmod u+w; /usr/bin/find /home/lars/WRT/kamikaze/build_dir/target-cris_uClibc-0.9.30.1/DAIM/ -name config.guess | xargs -r -n1 cp /home/lars/WRT/kamikaze/scripts/config.guess; /usr/bin/find /home/lars/WRT/kamikaze/build_dir/target-cris_uClibc-0.9.30.1/DAIM/ -name config.sub | xargs -r chmod u+w; /usr/bin/find /home/lars/WRT/kamikaze/build_dir/target-cris_uClibc-0.9.30.1/DAIM/ -name config.sub | xargs -r -n1 cp /home/lars/WRT/kamikaze/scripts/config.sub; AR=cris-openwrt-linux-uclibc-ar AS="cris-openwrt-linux-uclibc-gcc -c -Os -pipe -funit-at-a-time -fhonour-copts" LD=cris-openwrt-linux-uclibc-ld NM=cris-openwrt-linux-uclibc-nm CC="cris-openwrt-linux-uclibc-gcc" GCC="cris-openwrt-linux-uclibc-gcc" CXX="cris-openwrt-linux-uclibc-g++" RANLIB=cris-openwrt-linux-uclibc-ranlib STRIP=cris-openwrt-linux-uclibc-strip OBJCOPY=cris-openwrt-linux-uclibc-objcopy OBJDUMP=cris-openwrt-linux-uclibc-objdump SIZE=cris-openwrt-linux-uclibc-size CFLAGS="-Os -pipe -funit-at-a-time -fhonour-copts " CXXFLAGS="-Os -pipe -funit-at-a-time -fhonour-copts " CPPFLAGS="-I/home/lars/WRT/kamikaze/staging_dir/target-cris_uClibc-0.9.30.1/usr/include -I/home/lars/WRT/kamikaze/staging_dir/target-cris_uClibc-0.9.30.1/include -I/home/lars/WRT/kamikaze/staging_dir/toolchain-cris_gcc-4.3.3_uClibc-0.9.30.1/usr/include -I/home/lars/WRT/kamikaze/staging_dir/toolchain-cris_gcc-4.3.3_uClibc-0.9.30.1/include " LDFLAGS="-L/home/lars/WRT/kamikaze/staging_dir/target-cris_uClibc-0.9.30.1/usr/lib -L/home/lars/WRT/kamikaze/staging_dir/target-cris_uClibc-0.9.30.1/lib -L/home/lars/WRT/kamikaze/staging_dir/toolchain-cris_gcc-4.3.3_uClibc-0.9.30.1/usr/lib -L/home/lars/WRT/kamikaze/staging_dir/toolchain-cris_gcc-4.3.3_uClibc-0.9.30.1/lib "  config_BUILD_CFLAGS="-02 /home/lars/WRT/kamikaze/staging_dir/target-cris_uClibc-0.9.30.1/usr"   ./configure --target=cris-openwrt-linux --host=cris-openwrt-linux --build=i486-linux-gnu --program-prefix="" --program-suffix="" --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls  --disable-ipv6 --with_sqlite="/home/lars/WRT/kamikaze/staging_dir/target-cris_uClibc-0.9.30.1/usr/include"  ; fi; )
touch /home/lars/WRT/kamikaze/build_dir/target-cris_uClibc-0.9.30.1/DAIM/.configured_
make -C /home/lars/WRT/kamikaze/build_dir/target-cris_uClibc-0.9.30.1/DAIM AR=cris-openwrt-linux-uclibc-ar AS="cris-openwrt-linux-uclibc-gcc -c -Os -pipe -funit-at-a-time -fhonour-copts" LD=cris-openwrt-linux-uclibc-ld NM=cris-openwrt-linux-uclibc-nm CC="cris-openwrt-linux-uclibc-gcc" GCC="cris-openwrt-linux-uclibc-gcc" CXX="cris-openwrt-linux-uclibc-g++" RANLIB=cris-openwrt-linux-uclibc-ranlib STRIP=cris-openwrt-linux-uclibc-strip OBJCOPY=cris-openwrt-linux-uclibc-objcopy OBJDUMP=cris-openwrt-linux-uclibc-objdump SIZE=cris-openwrt-linux-uclibc-size CFLAGS="-Os -pipe -funit-at-a-time -fhonour-copts"
make[4]: Entering directory `/home/lars/WRT/kamikaze/build_dir/target-cris_uClibc-0.9.30.1/DAIM'
cris-openwrt-linux-uclibc-g++ -static -DHAVE_EXPAT_CONFIG_H -pthread -ldl   -o daim *.cpp protocols/*.cpp \
        protocols/j1587/*.cpp protocols/j1587volvo/*.cpp protocols/j1939/*.cpp valuecollector/*.cpp

The first bold is where i find sqlite3.h and the second is where i find libsqlite3.a .so and so on.

(Last edited by ElderLars on 15 Feb 2010, 08:46)

The discussion might have continued from here.