Previous: , Up: Native Windows Support   [Contents][Index]


14.8 Visual Studio Compatibility

The lib-msvc-compat module detects whether the linker supports --output-def when building a library. That parameter is used to generate a DEF file for a shared library (DLL). DEF files are useful for developers that use Visual Studio to develop programs that links to your library. See the GNU LD manual for more information.

There are other ways to create a DEF file, but we believe they are all sub-optimal to using --output-def during the build process. The variants we have considered include:

If you are using libtool to build your shared library, here is how to use this module. Import lib-msvc-compat to your project, and then add the following lines to the Makefile.am that builds the library:

if HAVE_LD_OUTPUT_DEF
libfoo_la_LDFLAGS += -Wl,--output-def,libfoo-$(DLL_VERSION).def
libfoo-$(DLL_VERSION).def: libfoo.la
defexecdir = $(libdir)
defexec_DATA = libfoo-$(DLL_VERSION).def
DISTCLEANFILES += $(defexec_DATA)
endif

The DLL_VERSION variable needs to be defined. It should be the shared library version number used in the DLL filename. For Windows targets you compute this value from the values you pass to Libtool’s -version-info. Assuming you have variables LT_CURRENT and LT_AGE defined for the CURRENT and AGE libtool version integers, you compute DLL_VERSION as follows:

DLL_VERSION=`expr ${LT_CURRENT} - ${LT_AGE}`
AC_SUBST(DLL_VERSION)

Previous: Native Windows Support without MSVC Support, Up: Native Windows Support   [Contents][Index]