[Xlibs] Shared library support on Cygwin
Harold L Hunt II
Tue, 13 Jan 2004 23:43:40 -0500
Keith Packard wrote:
> Around 13 o'clock on Jan 13, Harold L Hunt II wrote:
>>1) We need to set "LDFLAGS = -no-undefined" for all libraries that do
>>not export undefined symbols.
> I believe this can't be used in Xlib because of pthread functions called
> while threading is enabled -- on some systems, these functions are found
> in -lpthread, and Xlib isn't explicitly linked to pthread to avoid mapping
> that file in every application on the system.
I never understood "-no-undefined" to operate in that manner. From the
GNU Autotools book
Modern architectures allow us to create shared libraries with
undefined symbols, provided those symbols are resolved (usually by the
executable which loads the library) at runtime. Unfortunately, there are
some architectures (notably AIX and Windows) which require that all
symbols are resolved when the library is linked. If you know that your
library has no unresolved symbols at link time, then adding this option
tells libtool that it will be able to build a shared library, even on
architectures which have this requirement.
That wording has always given me the impression that shared libraries
simply would not be built on platforms that don't allow undefined
symbols at link time unless you pass the flag. It doesn't say anything
about changing the behavior on platforms that do support undefined
symbols in shared libraries at link time.
Am I reading the docs wrong and/or have you thoroughly explored this
before or are you reading the docs just like me?
>>2) This may be related to #1... but Xau is being directly linked when
>>X11 is linked. Currently, Xau is built as static (but the question is,
>>does it have to be static, or does it not export undefined symbols?); on
>>Cygwin, shared libraries cannot be linked to static libraries, so X11
>>will be forced to be static only if linked to a static Xau.
> The few Xau functions used in Xlib used to be compiled by linking the
> source files into the Xlib directory and building them there. I changed
> this to build Xau as a shared library and just use that. I don't know if
> this is the right way of doing stuff. If you want to change this, I
> suggest using the same mechanism as used by xtrans -- have Xau install the
> necessary source files into an include directory and building them into
> Xlib by creating a .c file that references them.
> If you just want to leave stuff alone, you should be able to build/install
> Xau and then X11 will use the shared version of the library that should
> get installed just fine.
> I don't have a strong opinion here; sharing code is good, but there aren't
> a huge number of applications using other Xau code, and having another
> library mapped into ever X application is bad.
Okay. I am building Xau as a shared lib. I could not remember if Xau
was the lib that we were discussing that could not be built as a shared
lib... apparently it was some other lib. Problem solved.
Thanks for your input,