Subject: shared libraries
To: None <current-users@NetBSD.ORG>
From: Grzegorz Wojtowicz <grzesiek@ajax.umcs.lublin.pl>
List: current-users
Date: 01/28/1997 21:14:07
Hi
Porting software from other OS's to netbsd makes me sometimes spend a lot
of time. Apart from the fact that its poor POSIX compliant the problems
arise when i have to patch original include files.
But thats not the point of this subject.
My question is: How does netbsd treat shared libs and if it differs
significantly from other unixes ?
And could anyone give more detailed way how to make shared lib

afaik : # ld -Bshareable -o libfoo.so.x.x $(OBJFILES.o compiled with
-fpic)   -l(any libs needed here)

will do fine.
However lets say that we just want to open it:

#include <stdio.h>
#include <dlfcn.h>
main()
{	void *libptr;
	if ( libptr = dlopen("/...libfoo.so.x.x", RTLD_LAZY) )
	{
		printf("Open successfull\n");
		...
	}
} 

It compiles well but fails after being executed:
/usr/libexec/ld.so: undeclared reference __bleblebleble from libfoo.so.x.x

even though thereis __bleblebleble declared in libfoo.so.x.x.

To sidestep such behaviour one can add -lfoo :
# gcc -o main main.c -lfoo 
instead of 
# gcc -o main main.c 
but is there any sense of doing so ???!!

AFAIK the object files compiled in  libfoo.a and libfoo.so.x.x are the
same not mentioning their position code dependency.

I checked this behaviour for libc,libm,libX11 and other core distribution
libs and they worked fine (read : dont give : undeclared reference
__blebleble in libfoo.so.x.x)
but for e.g. libkaffe_vm.so.x.x , libACE.so.x.x and others this is a
problem.
I assume they just were not compiled properly 
or is it a gcc2.7.2 bug/feature.

Sorry for -current but i couldnt find any response elsewhere.

Greetings
		gelo.

P.S.
Why # gcc -Xlinker -Bshareable (or -Wl,-Bshareable) complains about 
mutually exclusive '-Bshareable' and '-e' flags. I cant see '-e' here.