Subject: shared libraries
To: None <current-users@NetBSD.ORG>
From: Grzegorz Wojtowicz <>
List: current-users
Date: 01/28/1997 21:14:07
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 $(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>
{	void *libptr;
	if ( libptr = dlopen("/", RTLD_LAZY) )
		printf("Open successfull\n");

It compiles well but fails after being executed:
/usr/libexec/ undeclared reference __bleblebleble from

even though thereis __bleblebleble declared in

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 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
but for e.g. , and others this is a
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.


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