(Not sure if openwrt-users or opwnert-devel is the most appropriate
list for this; am sending to openwrt-devel after having had no reply
from openwrt-users)

---------- Forwarded message ----------
From: Jonathan Hunter <jmhunt...@gmail.com>
Date: 2009/4/26
Subject: Compiling simple app using sqlite library
To: openwrt-us...@lists.openwrt.org


Hi,

I must be missing something simple here. Can anybody point me in the
right direction?

I am running kamikaze (8.09, r15397), updated from the latest SVN and
patched with https://dev.openwrt.org/attachment/ticket/4975/fix-oops.diff
so that my WRT54G boots.

Using 'make menuconfig', I have added the
"Libraries/database/libsqlite3" package and also "Base
system/libpthread" (needed by sqlite, I think).

I am trying to compile the example sqlite C app from
http://www.sqlite.org/quickstart.html, but it isn't working. The code
works fine on my local PC, but hangs when I run it on my router.

Local output:
$ cc -o sqlite-sample -lsqlite3 sqlite-sample.c
$ ./sqlite-sample test "select 1"
1 = 1

Router output:

$ 
/home/jonathan/kamikaze/OpenWrt-SDK-brcm-2.4-for-Linux-i686/staging_dir/toolchain-mipsel_gcc3.4.6/bin/mipsel-linux-uclibc-gcc
 \
 -I/home/jonathan/kamikaze/8.09/staging_dir/mipsel/usr/include \
 -L/home/jonathan/kamikaze/8.09/staging_dir/mipsel/usr/lib \
 -I/home/jonathan/kamikaze/OpenWrt-SDK-brcm-2.4-for-Linux-i686/staging_dir/toolchain-mipsel_gcc3.4.6/include
\
 -lsqlite3 -o sqlite-sample sqlite-sample.c
r...@openwrt:/# ./sqlite-sample test "select 1"
(just hangs)

Running strace on the router, it hangs here:
r...@openwrt:/# strace ./sqlite-sample test "select 1"
[...]
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=405559, ...}) = 0
close(3)                                = 0
stat("/lib/ld-uClibc.so.0", {st_mode=S_IFREG|0755, st_size=20694, ...}) = 0
mprotect(0x2ac8a000, 4096, PROT_READ)   = 0
mprotect(0x2acde000, 4096, PROT_READ)   = 0
mprotect(0x2aaec000, 4096, PROT_READ)   = 0
ioctl(0, TIOCNXCL, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TIOCNXCL, {B38400 opost isig icanon echo ...}) = 0
getpid()                                = 1081
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
setrlimit(RLIMIT_STACK, {rlim_cur=2040*1024, rlim_max=RLIM_INFINITY}) = 0
rt_sigaction(SIGRT_0, {SIG_DFL, [],
SA_STACK|SA_INTERRUPT|SA_SIGINFO|SA_NOCLDWAIT|0x2c8cf24}, NULL, 16) =
0
rt_sigaction(SIGRT_1, {SIG_DFL, [],
SA_STACK|SA_INTERRUPT|SA_SIGINFO|SA_NOCLDWAIT|0x2c8cfe0}, NULL, 16) =
0
rt_sigaction(SIGRT_2, {SIG_DFL, [],
SA_STACK|SA_INTERRUPT|SA_SIGINFO|SA_NOCLDWAIT|0x2c8d134}, NULL, 16) =
0
rt_sigprocmask(SIG_BLOCK, [RT_0], NULL, 16) = 0
rt_sigprocmask(SIG_UNBLOCK, [RT_1], NULL, 16) = 0
brk(0)                                  = 0x440ec0
brk(0x441ec0)                           = 0x441ec0
brk(0x442000)                           = 0x442000
[This is where it hangs. Full strace output here: http://pastebin.ca/1403242 ]


I then wondered if the libraries were mismatched, so tried to compile
the app with "-static" - but couldn't get that working at all:

$ 
/home/jonathan/kamikaze/OpenWrt-SDK-brcm-2.4-for-Linux-i686/staging_dir/toolchain-mipsel_gcc3.4.6/bin/mipsel-linux-uclibc-gcc
\
 -I/home/jonathan/kamikaze/8.09/staging_dir/mipsel/usr/include \
 -L/home/jonathan/kamikaze/8.09/staging_dir/mipsel/usr/lib \
 -I/home/jonathan/kamikaze/OpenWrt-SDK-brcm-2.4-for-Linux-i686/staging_dir/toolchain-mipsel_gcc3.4.6/include
\
 -lsqlite3 -o sqlite-sample -static sqlite-sample.c
/tmp/ccSIqYdS.o: In function `main':
sqlite-sample.c:(.text+0x1d8): undefined reference to `sqlite3_open'
sqlite-sample.c:(.text+0x204): undefined reference to `sqlite3_errmsg'
sqlite-sample.c:(.text+0x250): undefined reference to `sqlite3_close'
sqlite-sample.c:(.text+0x2a0): undefined reference to `sqlite3_exec'
sqlite-sample.c:(.text+0x2fc): undefined reference to `sqlite3_free'
sqlite-sample.c:(.text+0x314): undefined reference to `sqlite3_close'
collect2: ld returned 1 exit status
$ ls /home/jonathan/kamikaze/8.09/staging_dir/mipsel/usr/lib/libsqlite*
/home/jonathan/kamikaze/8.09/staging_dir/mipsel/usr/lib/libsqlite3.a
/home/jonathan/kamikaze/8.09/staging_dir/mipsel/usr/lib/libsqlite3.so
/home/jonathan/kamikaze/8.09/staging_dir/mipsel/usr/lib/libsqlite3.so.0
/home/jonathan/kamikaze/8.09/staging_dir/mipsel/usr/lib/libsqlite3.so.0.8.6


What am I missing / what can I try next? Is it just me?! :-)

Many thanks,

Jonathan

--
"If we knew what it was we were doing, it would not be called
research, would it?"
     - Albert Einstein
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to