Hi Kirill, > If you look at commands executed by libtool when it creates a DLL, > you may see that it runs $NM on all object files which go into DLL. > Then it uses some awk script to generate list of all `extern` symbols > defined in those object files. Libtool then appends each symbol with > `-link -export:` so link.exe will export all of them. > ... > I don't like how libtool handles this. This may result in unwanted > symbols to be exported. > > I wish we had some option to pass to LT_INIT() to disable this behavior, > but keep old behavior as default.
I'm not the libtool maintainer, but I think the major reason for the behaviour of "libtool --mode=link" on MSVC is to be compatible with the behaviour on other platforms, in particular ELF-based ones. On these platforms, when you create a shared library ("gcc -shared ..."), it exports all global symbols. Which set of symbols would you want to be exported by default? Authors of shared libraries typically use one of various techniques [1] to decide which symbols to export. There is no single technique for all possible situations. Bruno [1] https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html