can't compile test code for embedded mysql

|

[phpwiki]
have had no luck with the test code and can't figure out why it's failing.
google doesn't seem to be of help. mysql.com doesn't seem to indicate any
problems with mysql embedded. and my test embedded build absolutely
refuses to link. if i do the build/link in one step i get an undefined
function mysql_server_init, if I do it in two steps I get complaints about
references to compress which I can't figure out how to resolve.

there doesn't seem to be anything special about linking the embedded db
according to the docs. the only diff between embedded and non-embedded is
that mysql_init_server() is not an empty stub in the embedded version.
getting one or the other is just a matter of linking against mysqld.a or
mysql_client.a. regardless of which one I use I get an undefined funciton
error.

my test.c code is:

#include
#include
#include
#include
int
main ()
{
mysql_server_init(0, NULL, NULL);
return 0;
}

building with gcc:

gcc -o test.out -I/usr/include/mysql -L/usr/lib/mysql -lpthread \
-lcrypt -lnsl -lm -lpthread -lc -lnss_files -lnss_dns -lresolv \
-lc -lnss_files -lnss_dns -lresolv -lrt -lwrap -lpthread -lmygcc \
test.c

i get:

/tmp/ccyGdUJD.o(.text+0x1a): In function `main':
: undefined reference to `mysql_server_init'
collect2: ld returned 1 exit status

i can see to compile it if I do the compile in two stages by first
creating the object file with gcc -c test.o .... test.c and then gcc -o
test test.o but I need to add "-lz" to get passed the undefined refs to
compress. if I do it in one pass, I still get the error above. very
curious.

thanks to [this japanese site|http://www.mysql.gr.jp/mysqlml/mysql/msg/5850]
for help with the compiler option "-lz".

Update: Following the instrux closely on the
[mysql embedded compile|http://dev.mysql.com/doc/mysql/en/libmysqld-example.html], that is using their example code and makefile allows the embedded server to compile without error. seems the shib configure file just needs some updating.