The MSVC linker doesn't have a -L option, and doesn't understand posix paths. Move the paths to an envvar (LINK) with a prefix (-LIBPATH:) This patch is against Libtool 2.2 * libltdl/m4/libtool.m4: Add new tag variables to specify to what variable (dashL_envvar) -L options should be moved, and what to prepend to the -L path (dashL_envvar_spec). * libltdl/config/ltmain.m4sh (func_dashL_to_envvar): New function that moves -L options to a variable. * libltdl/config/ltmain.m4sh (func_mode_link): Prior to linking, call above function if dashL_envvar is set. Index: libtool/libltdl/config/ltmain.m4sh =================================================================== --- libtool.orig/libltdl/config/ltmain.m4sh +++ libtool/libltdl/config/ltmain.m4sh @@ -789,6 +789,36 @@ func_win32_libid () } +# func_dashL_to_envvar deplibs_variable deplibs... +func_dashL_to_envvar () +{ + deplibs_variable=$1 + shift + tmp_libs= + for deplib; do + case $deplib in + -L*) + func_stripname '-L' '' "$deplib" + env_path=$func_stripname_result + case $host_os in + mingw*) + env_path=`cmd \\\\/C echo "$env_path " | $SED -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin*) + env_path=`cygpath -w "$env_path"` + ;; + esac + eval $dashL_envvar="\"\$$dashL_envvar $dashL_envvar_spec$env_path\"" + ;; + *) + tmp_libs="$tmp_libs $deplib" + ;; + esac + done + eval $deplibs_variable="\"$tmp_libs\"" +} + + # func_infer_tag arg # Infer tagged configuration to use if any are available and @@ -6328,6 +6358,19 @@ EOF test "X$libobjs" = "X " && libobjs= fi + case $pass/$dashL_envvar in + link/) ;; + link/*) + # Move all -L options to the environment variable + # specified by $dashL_envvar. + eval save_dashL_envvar="\"\$$dashL_envvar\"" + eval cmds=\"\$cmds~$dashL_envvar="$save_dashL_envvar"\" + + func_dashL_to_envvar deplibs $deplibs + export $dashL_envvar + ;; + esac + save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" @@ -6556,6 +6599,25 @@ EOF compile_deplibs="$new_libs" + case $pass/$dashL_envvar in + link/) ;; + link/*) + # Move all -L options to the environment variable + # specified by $dashL_envvar. + eval save_dashL_envvar="\"\$$dashL_envvar\"" + + func_dashL_to_envvar compile_deplibs $compile_deplibs + eval prepend_dashL_envvar="$dashL_envvar=\\\"\$$dashL_envvar\\\"" + compile_command="$prepend_dashL_envvar $compile_command" + eval $dashL_envvar="\"$save_dashL_envvar\"" + + func_dashL_to_envvar finalize_deplibs $finalize_deplibs + eval prepend_dashL_envvar="$dashL_envvar=\\\"\$$dashL_envvar\\\"" + finalize_command="$prepend_dashL_envvar $finalize_command" + eval $dashL_envvar="\"$save_dashL_envvar\"" + ;; + esac + compile_command="$compile_command $compile_deplibs" finalize_command="$finalize_command $finalize_deplibs" Index: libtool/libltdl/m4/libtool.m4 =================================================================== --- libtool.orig/libltdl/m4/libtool.m4 +++ libtool/libltdl/m4/libtool.m4 @@ -5222,6 +5222,10 @@ _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) +_LT_TAGDECL([], [dashL_envvar], [1], + [When linking, move all paths specified with -L options to this variable]) +_LT_TAGDECL([], [dashL_envvar_spec], [1], + [When moving paths with dashL_envvar, prepend this to each path]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects])