Getting a linker warning about incompatible libraries.

From: Date: Tue, 18 Jan 2011 10:24:39 +0000
Subject: Getting a linker warning about incompatible libraries.
Groups: php.internals.win 
Request: Send a blank email to internals-win+get-757@lists.php.net to get a copy of this message
Hi. I'm getting (and have always got) the following message for various extensions ... LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library I get this message for php_gd, php_gmp, php_ldap and php_tidy. In reading Linker Tools Warning LNK4098 [1], it looks quite important to select the right sort of libraries (debug/non_debug, single/multi threaded, static/dynamic). I'm building with --disable-zts for CLI, CGI and WIN-CLI SAPIs. I'm guessing that there is less damage in linking the wrong library for a single threaded app than if I was building a multi-threaded SAPI and linked single threaded libraries. Is there a way of telling if the right library is linked for a DLL file? The attached patch (against branch PHP_5_3) adds the following macro to the config.w32 files. if (PHP_ZTS != "yes") { ADD_FLAG ("LDFLAGS_xxxxx", "/NODEFAULTLIB:LIBCMT"); } where xxxx is the module name and this has removed the warning and the limited testing I'm doing doesn't show up any problems (i.e. all my code still works that uses these extensions). I wonder if configure should be setting LD_FLAGS in the Makefile to /NODEFAULTLIB:LIBCMT for --disable-zts automatically. It is done for the php5.dll (PHP_LDFLAGS), but not for any of the extension dll files. Regards, Richard. [1] http://msdn.microsoft.com/en-us/library/6wtdswk0(VS.90).aspx -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

Index: gd/config.w32 =================================================================== --- gd/config.w32 (revision 307557) +++ gd/config.w32 (working copy) @@ -66,7 +66,10 @@ /D USE_GD_IOCTX \ /D MSWIN32 \ "); - + if (PHP_ZTS != "yes") { + ADD_FLAG ("LDFLAGS_GD", "/NODEFAULTLIB:LIBCMT"); + } + PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd" ); } else { WARNING("gd not enabled; libraries and headers not found"); Index: gmp/config.w32 =================================================================== --- gmp/config.w32 (revision 307557) +++ gmp/config.w32 (working copy) @@ -9,6 +9,9 @@ EXTENSION("gmp", "gmp.c"); AC_DEFINE('HAVE_GMP', 1, 'GMP support'); AC_DEFINE('HAVE_MPIR', 1, 'MPIR support'); + if (PHP_ZTS != "yes") { + ADD_FLAG ("LDFLAGS_GMP", "/NODEFAULTLIB:LIBCMT"); + } } else { WARNING("GMP not enabled; libraries and headers not found"); } Index: ldap/config.w32 =================================================================== --- ldap/config.w32 (revision 307557) +++ ldap/config.w32 (working copy) @@ -25,6 +25,9 @@ AC_DEFINE('HAVE_LDAP_START_TLS_S', 1); AC_DEFINE('HAVE_LDAP', 1); AC_DEFINE('LDAP_DEPRECATED', 1); + if (PHP_ZTS != "yes") { + ADD_FLAG ("LDFLAGS_LDAP", "/NODEFAULTLIB:LIBCMT"); + } } else { WARNING("ldap not enabled; libraries and headers not found"); Index: tidy/config.w32 =================================================================== --- tidy/config.w32 (revision 307557) +++ tidy/config.w32 (working copy) @@ -15,6 +15,9 @@ if (!PHP_TIDY_SHARED) { ADD_DEF_FILE("ext\\tidy\\php_tidy.def"); } + if (PHP_ZTS != "yes") { + ADD_FLAG ("LDFLAGS_TIDY", "/NODEFAULTLIB:LIBCMT"); + } } else { WARNING("tidy not enabled; libraries and headers not found"); }
« previous php.internals.win (#757) next »