Subject: Re: shared object problem
To: None <arnej@math.ntnu.no, port-alpha@NetBSD.ORG, port-pmax@NetBSD.ORG>
From: Ross Harvey <ross@teraflop.com>
List: port-pmax
Date: 07/25/1998 06:00:02
> From: Arne H Juul <arnej@math.ntnu.no>
>
> I've been looking at perl and trying to figure out why dynamic
> module loading doesn't work, and I've found that it's because
> the dynamic modules can't get the symbols back in the main program
> right.  Appended is a test case, compile with:
>
> # cc main.c -o main
> # cc -c -fPIC fred.c
> # ld -x -shared fred.o -o fred.so
> # ./main
>
> I think this should work, at least it does on NetBSD/i386 and
> IRIX/mips, so I guess it's ld.elf_so that doesn't work right.


With a slight command adjustment, it works for me. You just have to get
the magic incantation right.  And be careful, mispronouncing the spells
can get you turned into a frog or something. :-)

It would be cool if the entire problem with dynamic programs was this
simple.

Here is what I did:

	cc -Wl,--export-dynamic main.c -o main
	cc -c -fPIC fred.c
	ld -x -shared fred.o -o fred.so
	./main

(For testing it doesn't matter, but to install this successfully note that
the script needs a -rpath and a -soname also.)

Ross