Use the new u*_cmp2 functions.
[gnulib.git] / doc / ld-output-def.texi
1 @node Visual Studio Compatibility
2 @section Visual Studio Compatibility
3 @cindex DEF files
4 @cindex LD DEF files
5
6 The @code{lib-msvc-compat} module detects whether the linker supports
7 @code{--output-def} when building a library.  That parameter is used
8 to generate a DEF file for a shared library (DLL).  DEF files are
9 useful for developers that use Visual Studio to develop programs that
10 links to your library.  See the GNU LD manual for more information.
11
12 There are other ways to create a DEF file, but we believe they are all
13 sub-optimal to using @code{--output-def} during the build process.
14 The variants we have considered include:
15
16 @itemize @bullet
17 @item Use DUMPBIN /EXPORTS.
18 The tool does not generate DEF files directly, so its output needs to
19 be post processed manually.  The tool is documented to potentially not
20 work with non-MS development tools
21 (@url{http://support.microsoft.com/kb/131313/en-us}), which is the
22 case when MinGW is used to build the library.
23
24 @item Use IMPDEF.
25 There is a tool called IMPDEF
26 (@url{http://sei.pku.edu.cn/~caodg/course/c/reference/win32/tools/dlltool.html})
27 that can generate DEF files.  However, it is not part of a standard
28 Visual Studio installation.  Further, it is documented as being an
29 unreliable process.
30
31 @item Use DLLTOOL.
32 The dlltool is part of the MinGW suite, and thus not part of a
33 standard Visual Studio installation.  The documentation for the IMPDEF
34 tool claims that DLLTOOL is the wrong tool for this job.  Finally,
35 DLLTOOL does not generate DEF files directly, so it requires
36 post-processing of the output.
37
38 @end itemize
39
40 If you are using libtool to build your shared library, here is how to
41 use this module.  Import @code{lib-msvc-compat} to your project, and
42 then add the following lines to the @code{Makefile.am} that builds the
43 library:
44
45 @smallexample
46 if HAVE_LD_OUTPUT_DEF
47 libfoo_la_LDFLAGS += -Wl,--output-def,libfoo-$(DLL_VERSION).def
48 defexecdir = $(bindir)
49 defexec_DATA = libfoo-$(DLL_VERSION).def
50 DISTCLEANFILES += $(defexec_DATA)
51 endif
52 @end smallexample
53
54 The @code{DLL_VERSION} variable needs to be defined.  It should be the
55 shared library version number used in the DLL filename.  For Windows
56 targets you compute this value from the values you pass to Libtool's
57 @code{-version-info}.  Assuming you have variables @code{LT_CURRENT}
58 and @code{LT_AGE} defined for the @code{CURRENT} and @code{AGE}
59 libtool version integers, you compute @code{DLL_VERSION} as follows:
60
61 @smallexample
62 DLL_VERSION=`expr $@{LT_CURRENT@} - $@{LT_AGE@}`
63 AC_SUBST(DLL_VERSION)
64 @end smallexample