libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Difficulties with dlpreopen interface


From: Ineiev
Subject: Re: Difficulties with dlpreopen interface
Date: Tue, 21 Apr 2009 09:38:33 +0400

Hello, Ralf;

On 4/18/09, Ralf Wildenhues <address@hidden> wrote:
>> cygwin simply refused to link the application.
> Can you show the error you're getting under Cygwin?
I couldn't reproduce it, sorry; I evidently mistook something.
it builds well; the libraries are not opened when the application run.

> Can you try adding -no-undefined to the library link flags
Yes, it fixed the sample (after removing comments from lib.sym):
when shared libraries are not disabled, it loads the modules as expected.

Thank you!

> This build completes for me when I use --disable-shared.
Indeed; yet I couldn't write a working example.
I rewrote lib.c like this
(http://ineiev.users.sourceforge.net/samples/dlpo-0.0.2.tar.gz):

#include"lib.h"
#include<stdio.h>
#include<libltdl/ltdl.h>
#if LIB_NO == 0
# define preloaded_symbols lt_lib0_LTX_preloaded_symbols
# define init_lib init_lib0
# define LIB_NAME "lib0"
#else
# define preloaded_symbols lt_lib1_LTX_preloaded_symbols
# define init_lib init_lib1
# define LIB_NAME "lib1"
#endif
extern const lt_dlsymlist*preloaded_symbols;
void
bar(void){printf("bar() from %s\n",LIB_NAME);}
void
foo(void){printf("foo() from %s: ",LIB_NAME);bar();}
static const struct func_table funcs={bar,foo};
static int
preload_callback(lt_dlhandle h){return 0;}
const struct func_table*
init_lib(void)
{
 if(lt_dlpreload(&preloaded_symbols))return 0;
 lt_dlpreload_open (LIB_NAME, preload_callback);
 return &funcs;
}

I'm not quite sure where actions from init_lib() should be, in lib.c or
in main(); in either case I had to put a declaration in the source.

I also changed exported symbols list: from lib0 init_lib0 is exported,
from lib1 --- init_lib1.

This resulted in

libtool: link: gcc -g -O2 .libs/dlpoS.o -o dlpo dlpo-dlpo.o
./.libs/lib0.a ./.libs/lib1.a /home/dti/libtool/lib/libltdl.so -ldl
-Wl,-rpath -Wl,/home/dti/libtool/lib -Wl,-rpath
-Wl,/home/dti/libtool/lib
./.libs/lib1.a(lib1_la-lib.o)(.text+0x0): In function `bar':
../m/lib.c:16: multiple definition of `bar'
./.libs/lib0.a(lib0_la-lib.o)(.text+0x0):../m/lib.c:16: first defined here
./.libs/lib1.a(lib1_la-lib.o)(.text+0x1c): In function `foo':
../m/lib.c:18: multiple definition of `foo'
./.libs/lib0.a(lib0_la-lib.o)(.text+0x1c):../m/lib.c:18: first defined here
./.libs/lib0.a(lib0_la-lib.o)(.text+0x4b): In function `init_lib0':
lib.c: undefined reference to `lt_lib0_LTX_preloaded_symbols'
./.libs/lib1.a(lib1_la-lib.o)(.text+0x4b): In function `init_lib1':
lib.c: undefined reference to `lt_lib1_LTX_preloaded_symbols'
collect2: ld returned 1 exit status
libtool: link: rm -f ".libs/dlpoS.o"

The multiple definitions were probably expected, but undefined references
mean I did something wrong; I couldn't figure out what from the info file.

Thanks,
   Ineiev




reply via email to

[Prev in Thread] Current Thread [Next in Thread]