[uClibc]Library dependency problems?

Tobias Anderberg tobias.anderberg at axis.com
Fri Oct 18 12:40:38 UTC 2002


I'm having a dependency problem with the dynamic linker, both on i386
and cris. Or so it seems...

Short version:

dltest uses dlopen("./testlib.so", RTDL_NOW);

testlib.so
  NEEDED  libdynamic1.so (call function 'hello')

  libdynamic1.so
     NEEDED  libdynamic2.so (defines symbol 'hello')

When running ./dltest I get

./dltest: symbol 'hello': can't resolve symbol

Long version:

It seems like there is a problem with resolving symbols in libraries
which is needed by another library loaded by the program. If I make
dltest NEED libdynamic1.so then it seems to be able to resolve hello,
but that shouln't be necessary!

Has anyone else seen this?

Code for testing:

% cat > dltest.c
#include <dlfcn.h>

int
main(void)
{
    void *shared_lib = dlopen("./testlib.so", RTLD_NOW);
    return 0;
}

% cat > testlib.c
void
dummy(void)
{
}

% cat > dynamic1.c
#include "inc.h"

void
dummy2(void)
{
        hello();
}

% cat > dynamic2.c
#include "inc.h"

void
hello(void)
{
        printf("hello, world\n");
}

Compile with (change names where appropiate, i.e. uclibc-gcc):

uclibc-gcc -c -fPIC testlib.c dynamic1.c dynamic2.c
uclibc-gcc -shared -o libdynamic2.so dynamic2.o
uclibc-gcc -shared -o libdynamic1.so dynamic1.o -ldynamic2
uclibc-gcc -shared -o testlib.so -o testlib -ldynamic1
uclibc-gcc -o dltest dltest.c -ldl

(Hopefully the copy/paste thing got everything)

-- 
tobias



More information about the uClibc mailing list