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 that builds the library:

libfoo_la_LDFLAGS += -Wl,--output-def,libfoo-$(DLL_VERSION).def
defexecdir = $(libdir)
defexec_DATA = libfoo-$(DLL_VERSION).def

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:


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