You can't do that. It doesn't have anything to do with the compiler.
You can't link statically with libdl, because there is no libdl.a.
This is because libdl is not a library at all. It's a linker map file.
I don't know enough about map files to explain what you can and
cannot do, but I can give a simple example or two.
There is /usr/lib/libintl.so and /usr/lib/libintl.a. libintl.a is
a link to null.a, which is simply an empty ar archive. This is logical,
since gettext() and friends are in libc. libintl.so exists for the
sole purpose of supporting applications which were built on the
old releases, where libintl really contained those functions.
If you start such application on a more recent Solaris, run time
linker will map functions from libintl to libc. There are no wrapper
functions in libintl, there are just pointers (of a kind) to libc.
Linker magic.
It's a bit more complicated with libdl and I never pursued the matter,
so I can't tell what is really going on, but I think that call to
dlopen() will invoke run time linker somehow and your library
will be linked in. If you look at the `nm /usr/lib/libdl.so' output,
you'll notice that sizes for dlopen() and friends are 8, unlike
all other functions (in other libraries) for which you'll see the size
of assembly code. libdl.a can't exist and libdl.so is a sort of
halucination. :-) It's always on the other side of a rainbow.
I don't think that ld and ld.so.1 man pages explain this in detail, so
you could try reading Linker and Library Guide, available somewhere
from http://docs.sun.com (HTML only). But, in the end, the answer will
be "you can't do that." Now, what was the question?
> Which combination of flags should I be using here?
You should try to answer one simple question: why do you want to do
that? I can understand that you want to link staticaly with libpng
or g++ library. But why with system libraries? Sun doesn't guarantee
that programs linked staticaly with system libraries will work on a
next release. In LP64 environment there is even more severe restriction.
There are no static libraries. OK, maybe one or two, for a low level
system dependant things.
I suppose you'll want to do something like this:
g++ -static your.objects.o your.libraries.a -shared
Sorry, I almost don't use gcc at all, so I don't know what it can do
in the linking phase. If you need esoteric things, I would suggest to
invoke ld directly. Or you could tell me what is it that you want to
have as a result, so we'll hopefully produce it in one way or another.
-- .-. .-. Life is a sexually transmitted disease. (_ \ / _) | dave@srce.hr | dave@fly.cc.fer.hr