[Top][All Lists]

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

Re: Questions on exporting functions from a shared library

From: Brian Dessent
Subject: Re: Questions on exporting functions from a shared library
Date: Thu, 18 Sep 2008 07:16:36 -0700

Jef Driesen wrote:

> What are the (dis)advantages of each method? I see differences in usage
> (see below), but are there technical differences as well?

It sounds like you already are aware of all the tradeoffs.  I don't
think there's a technical difference in the end, i.e. the results are
the same assuming that you mark the same set of functions.

Having to worry about disabling the declspec attributes when
building/using the static version of the library is not that big a
deal.  If you're using libtool you can already get this for free because
libtool always adds -DPIC even on Win32/PE where there is no meaningful
-fPIC, so you can just gate on that.  If you're not using libtool you
can just make up something, e.g. just document that users need to use
-DMYLIB_STATIC when they want to use the static version of your lib,
otherwise default to shared.

If you care about limiting the exported interface you should care about
symbol visibility for ELF systems too.  And once you have the declspec
macros set up it's not hard to simply hook into that for ELF visibility
as well.  There are some examples at

IMHO, these are all reasons why you should go with the declspec method
and ditch the .def file.  Having to keep things in sync in two separate
places is always extra work, plus the additional kludge of having to
jump through preprocessor hoops to maintain it sounds like a real pain.


reply via email to

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