[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: Ralf Wildenhues
Subject: Re: Questions on exporting functions from a shared library
Date: Sun, 5 Oct 2008 13:12:38 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

* Jef Driesen wrote on Thu, Oct 02, 2008 at 05:08:55PM CEST:
> mylib.exp: mylib.symbols
> if XYZ
>   $(CPP) -P -DMYLIB_XYZ_SUPPORT - < mylib.symbols | sed -e '/^$$/d' > $@
> else
>   $(CPP) -P - < mylib.symbols | sed -e '/^$$/d' > $@
> endif
> CLEANFILES = mylib.exp
> EXTRA_DIST = mylib.symbol
> One of the downside of this method is that I need to maintain the  
> separate symbols file (not a real issue). But more important is that  
> this setup is not supported by the msvc compiler. That compiler does not  
> export any function by default, unless a DEF file or the dllexport  
> attribute is used. But I don't know if it is possible to do a similar  
> trick for msvc, and generate the DEF file on the fly. And I don't want  
> to maintain two almost identical symbol files.

Can you just ship the symbol file in the source tarball, and use the
shipped file for msvc?  That hampers development of the code with msvc,
but should work for distribution.

> Note: How do can I detect whether the visibility attribute is supported?

For example with the gnulib module 'visibility'.

> where MYLIB_BUILD is always defined when building the library, and  
> MYLIB_STATIC should be defined for static building and linking.

Note that libtool defines PIC for you for the nonstatic code.

> BTW, is it possible to force automake to link my examples against the  
> static library, in case both the static and shared library are build?  
> Now I'm using a separate build tree with ./configure --disable-shared,  
> thus affecting the complete project, when I need statically linked 
> examples.

You can avoid using a separate tree, by adding -static to the link flags
(either to each testprog_LDFLAGS, or AM_LDFLAGS if all tests reside in a
separate directory).

Hope that helps.


reply via email to

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