Discussion:
link sqlite against dietlibc
Michael Graßl
2010-08-24 15:51:56 UTC
Permalink
Hello


I tried to link sqlite against the dietlibc-dev (debia sid 0.32) ond my
amd64 but i got some errors.

Any ideas how to fix them which value should PTHREAD_MUTEX_RECURSIVE
have and whats wrong with unixDlError ?

Best regards,
Mike

diet -v gcc -Werror -ggdb3 -c sqlite3.c
gcc -include /usr/lib/diet/include/dietref.h -Werror -ggdb3 -c sqlite3.c
-isystem /usr/lib/diet/include -D__dietlibc__
sqlite3.c: In function 'pthreadMutexAlloc':
sqlite3.c:15993: error: 'PTHREAD_MUTEX_RECURSIVE' undeclared (first use
in this function)
sqlite3.c:15993: error: (Each undeclared identifier is reported only once
sqlite3.c:15993: error: for each function it appears in.)
cc1: warnings being treated as errors
sqlite3.c: In function 'unixDlError':
sqlite3.c:27231: error: assignment discards qualifiers from pointer
target type
make: *** [sqlite3.o] Fehler 1
Gernot Tenchio
2010-08-24 17:13:34 UTC
Permalink
On Tue, 24 Aug 2010 17:51:56 +0200
Post by Michael Graßl
Hello
I tried to link sqlite against the dietlibc-dev (debia sid 0.32) ond my
amd64 but i got some errors.
Any ideas how to fix them which value should PTHREAD_MUTEX_RECURSIVE
Try this:

/opt/diet/bin/diet -v gcc -Werror
-DPTHREAD_MUTEX_RECURSIVE=PTHREAD_MUTEX_RECURSIVE_NP -ggdb3 -c sqlite3.c
Post by Michael Graßl
have and whats wrong with unixDlError ?
dlerror() is declared as "const char *dlerror(void);" in dietlibc which is
wrong. It should be "char *dlerror(void);".
Post by Michael Graßl
Best regards,
Mike
Gernot
Michael Graßl
2010-08-24 17:34:54 UTC
Permalink
Hello

by: Gernot
Post by Gernot Tenchio
dlerror() is declared as "const char *dlerror(void);" in dietlibc which is
wrong. It should be "char *dlerror(void);".
Is ther some work around for dlerror? A simple change of the dlfunc.h
isn't a good idea or?

By the way i looked in the manuals at linux it is a "char
*dlerror(void)" and at BSD (in my case OpenBSD) it is "const char
*dlerror(void)" so is there some OS dependencies?

Best regard,
Michael
Gernot Tenchio
2010-08-24 18:13:09 UTC
Permalink
On Tue, 24 Aug 2010 19:34:54 +0200
Post by Michael Graßl
Hello
by: Gernot
Post by Gernot Tenchio
dlerror() is declared as "const char *dlerror(void);" in dietlibc which is
wrong. It should be "char *dlerror(void);".
Is ther some work around for dlerror? A simple change of the dlfunc.h
isn't a good idea or?
Simply omit -Werror. :-)
Post by Michael Graßl
By the way i looked in the manuals at linux it is a "char
*dlerror(void)" and at BSD (in my case OpenBSD) it is "const char
*dlerror(void)" so is there some OS dependencies?
The Open Group Base Specifications at least says *char...

http://www.opengroup.org/onlinepubs/009695399/functions/dlerror.html

Gernot
Michael Graßl
2010-08-24 18:18:37 UTC
Permalink
Hallo again...
Post by Gernot Tenchio
Simply omit -Werror. :-)
Yeah that was what i tried and it compiled with warnings but now i have
the Problem that it want link the whole app togehter because it seems to
miss libdl and pthread allthough i add them with "-ldl....". whats
going wrong at the linking process?


#link sqlite3.c

gcc -include /usr/lib/diet/include/dietref.h -Wall -ggdb3 -c sqlite3.c
-DPTHREAD_MUTEX_RECURSIVE=PTHREAD_MUTEX_RECURSIVE_NP -isystem
/usr/lib/diet/include -D__dietlibc__
sqlite3.c: In function 'dotlockLock':
sqlite3.c:24058: warning: implicit declaration of function 'utimes'
sqlite3.c: In function 'unixDlError':
sqlite3.c:27231: warning: assignment discards qualifiers from pointer
target type


#linking all together now

gcc -nostdlib -static -L/usr/lib/diet/lib-x86_64
/usr/lib/diet/lib-x86_64/start.o -Wall -ggdb3 -o browse2.cgi browse.o
sqlite3.o gui.o filter.o content.o render.o -lpthread -ldl -isystem
/usr/lib/diet/include -D__dietlibc__ /usr/lib/diet/lib-x86_64/libc.a -lgcc
sqlite3.o: In function `closePendingFds':
/var/dev/sqlite3.c:23204: warning: >>> your multithreaded code
uses errno! <<<
sqlite3.o: In function `unixDlOpen':
/var/dev/sqlite3.c:27217: warning: Using 'dlopen' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/lib/diet/lib-x86_64/libc.a(vfprintf.o): In function `vfprintf':
vfprintf.c:(.text+0x15): warning: warning: the printf functions add
several kilobytes of bloat.
/usr/lib/diet/lib-x86_64/libc.a(stderr.o): In function `__fflush_stderr':
stderr.c:(.text+0x8): warning: warning: your code uses stdio (7+k bloat).
sqlite3.o: In function `pthreadMutexAlloc':
sqlite3.c:(.text+0x3694): undefined reference to `pthread_mutexattr_settype'
sqlite3.o: In function `dotlockLock':
sqlite3.c:(.text+0xac4c): undefined reference to `utimes'
/usr/lib/gcc/x86_64-linux-gnu/4.3.2/../../../../lib/libdl.a(dlopen.o):
In function `dlopen':
(.text+0x5): undefined reference to `__dlopen'
/usr/lib/gcc/x86_64-linux-gnu/4.3.2/../../../../lib/libdl.a(dlclose.o):
In function `dlclose':
(.text+0x1): undefined reference to `__dlclose'
/usr/lib/gcc/x86_64-linux-gnu/4.3.2/../../../../lib/libdl.a(dlsym.o): In
function `dlsym':
(.text+0x5): undefined reference to `__dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.3.2/../../../../lib/libdl.a(dlerror.o):
In function `dlerror':
(.text+0x1): undefined reference to `__dlerror'
collect2: ld returned 1 exit status
make: *** [all] Fehler 1
Felix von Leitner
2010-08-24 18:22:05 UTC
Permalink
Post by Michael Graßl
Yeah that was what i tried and it compiled with warnings but now i
have the Problem that it want link the whole app togehter because it
seems to miss libdl and pthread allthough i add them with
"-ldl....". whats going wrong at the linking process?
libdl is not available when you link statically.
The whole idea of libdl is that you link dynamically, not statically.

You can either patch sqlite to not depend on dlopen and friends, or use
the experimental dynamic dietlibc (make dyn).
Post by Michael Graßl
gcc -nostdlib -static -L/usr/lib/diet/lib-x86_64
/usr/lib/diet/lib-x86_64/start.o -Wall -ggdb3 -o browse2.cgi
browse.o sqlite3.o gui.o filter.o content.o render.o -lpthread -ldl
-isystem /usr/lib/diet/include -D__dietlibc__
/usr/lib/diet/lib-x86_64/libc.a -lgcc
/var/dev/sqlite3.c:23204: warning: >>> your multithreaded
code uses errno! <<<
This is a VERY bad sign. It means you did not compile multithreaded
code with -D_REENTRANT. This will probably fail at runtime, possibly in
mysterious and hard to reproduce ways.
Post by Michael Graßl
/var/dev/sqlite3.c:27217: warning: Using 'dlopen' in statically
linked applications requires at runtime the shared libraries from
the glibc version used for linking
This means the linker tried to link in libdl from glibc, which tells you
that using libdl with static linking is not a concept that makes sense
in the first place.

Felix
Felix von Leitner
2010-08-24 18:28:35 UTC
Permalink
Post by Michael Graßl
sqlite3.c:(.text+0xac4c): undefined reference to `utimes'
utimes is in libcompat for dietlibc, because it is not posix.

Mhh, actually, it IS in posix now. I'll move it to the regular library
in CVS.

You can turn off shared linking, dynamic extensions and thread-safety as
configure options for sqlite.

Felix

Loading...