libtool
[Top][All Lists]
Advanced

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

Re: different flags for static and shared


From: Ralf Wildenhues
Subject: Re: different flags for static and shared
Date: Sat, 25 Jul 2009 13:04:36 +0200
User-agent: Mutt/1.5.20 (2009-06-15)

Hello David,

* David Byron wrote on Tue, Jun 30, 2009 at 12:22:52AM CEST:
> Sorry if this is a FAQ.  I'm building a library using the pr-msvc-support
> branch of libtool so I'm using native MSVC tools.  When building a shared
> lib I'm doing one of the methods prescribed here:
> 
> http://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shar
> ed-Libraries.html
> 
> Specifically:
> 
>      #if BUILDING_LIBFOO && HAVE_VISIBILITY
>      #define LIBFOO_DLL_EXPORTED __attribute__((__visibility__("default")))
>      #elif BUILDING_LIBFOO && defined _MSC_VER
>      #define LIBFOO_DLL_EXPORTED __declspec(dllexport)
>      #elif defined _MSC_VER
>      #define LIBFOO_DLL_EXPORTED __declspec(dllimport)
>      #else
>      #define LIBFOO_DLL_EXPORTED
>      #endif
> 
> Trouble is, this doesn't handle the case where I'm building a static lib
> using MS tools.  In that case I (think I) want the macro to be empty.
> 
> I'm fine to jimmy around the preprocessor logic to use an addition symbol
> like LIBFOO_STATIC to have it end up that way, but I don't see a way to
> define LIBFOO_STATIC only when compiling the static lib.
> 
> In the case where a build directory is configured for static only (e.g.
> invoked with --disable-shared) I can add -DLIBFOO_STATIC to one of the
> CPPFLAGS variables, but if a build directory is configured for both, I don't
> see how to define LIBFOO_STATIC only in the static case.

libtool should be adding -DPIC only for the non-static objects,
that should allow you to distinguish between that and the objects
that are used for the DLL.

In case you are using convenience archives, you should note that
currently, libtool only creates one set of objects for them, not
two.  So you might have to pass the -static flag to convenience
archive creation in this case, or build two such archives.

Hope that helps.

Cheers,
Ralf




reply via email to

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