(2010/02/10 2:15), Trond Norbye wrote: > > On Feb 9, 2010, at 6:07 PM, Dustin wrote: > >> >> On Feb 9, 12:46 am, KaiGai Kohei<[email protected]> wrote: >> >>> I expected --enable-default-engine allows to link default_engine in static. >> >> It should (did last time I tried it). I'm not sure what issue >> you're having with that. > > Just a wild guess from me.. The create_instance function isn't referenced from > the memcached.c source so it's not linked into your binary at all.. Just try > to > edit memcached.c and initialize the create function to point to > create_instance > to force the linker to include it into your binary...
Maybe, this estimation is right. The manpage of dlopen(3) introduced an example: | If this program were in a file named "foo.c", you would build the program | with the following command: | | gcc -rdynamic -o foo foo.c -ldl The manpage of gcc(1) also said: | -rdynamic | Pass the flag -export-dynamic to the ELF linker, on targets that | support it. This instructs the linker to add all symbols, not only | used ones, to the dynamic symbol table. This option is needed for some | uses of "dlopen" or to allow obtaining backtraces from within a | program. Then, I tried as follows: $ make CFLAGS='-rdynamic' $ ./memcached -d -s /tmp/memcached.sock $ mcdclient.php add aaa xxxxx unix:///tmp/memcached.sock success to add [key:aaa, value:xxxxx] $ mcdclient.php get aaa unix:///tmp/memcached.sock 'aaa' => 'xxxxx' It works for me. > The way the loading in memcached works is that it tries to dlopen(NULL, ...) > and > then use dlsym to resolve the function.. You could try to use nm on memcached > to > see if it got a symbol named create_instance? But nm command shows the following result, even if without -rdynamic. $ ./memcached Could not find symbol "create_instance" in self: ./memcached: undefined symbol: create_instance $ nm ./memcached | grep create_instance 08054be0 T create_instance $ nm ./memcached | grep default_ 08055190 t default_arithmetic 080554a0 t default_destroy 080550d0 t default_flush 080550f0 t default_get 08054ad0 t default_get_info 08054e90 t default_get_stats 080554f0 t default_initialize 08055400 t default_item_allocate 080553e0 t default_item_delete 08055170 t default_item_release 08054e30 t default_reset_stats 08055140 t default_store 08054ae0 t default_unknown_command Thanks, -- OSS Platform Development Division, NEC KaiGai Kohei <[email protected]>
