Bruno Haible <br...@clisp.org> writes: >> Some ideas: >> >> 1) Should the sockets.m4 module unconditionally add LIBSOCKET to LDADD? >> >> 2) Should the gnulib-tool generated Makefile.am add LIBSOCKET to LDADD? > > No, LDADD has an effect on all executables. I don't want to link all my > programs against -lws2_32 just because one of them uses sockets. > > No, I don't want to add LIBSOCKET to the link dependencies of the 'close' > and 'fclose' either. It would also have the effect that all or nearly my > programs would link against -lws2_32. > > Dynamic loading of ws2_32,dll is not the solution either; it would still > have the effect of loading an extra library in programs that don't need it.
Right. >> Is there any other options? > > I propose to move the sockets related part of close() into the 'sockets' > module, and connect the close() code with the sockets related code at runtime > rather than at compile time. Like this (tested on mingw). Nice idea! It adds some complexity, but it makes the other code easier to understand once you have understood close-hook. I have tested it, and it seems to work for me on mingw and normal x86, and solves the problem. Please push it. /Simon