From 44e3db7ec34797705cf8802170cc4e739b9b3c2a Mon Sep 17 00:00:00 2001 From: Largo Date: Thu, 8 Oct 2026 12:38:39 +0200 Subject: [PATCH] Add library paths to $LDFLAGS on mswin too have_package put the /libpath: flags into $DLDFLAGS on mswin, but mkmf's try_link (have_func, have_library, ...) only uses $LDFLAGS, so every link check against the package failed on mswin and extensions silently built without HAVE_* features. mswin's mkmf Makefile already includes $(ldflags) in DLDFLAGS, so $LDFLAGS covers the final link too. Co-Authored-By: Claude Opus 5.5 --- lib/pkg-config.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pkg-config.rb b/lib/pkg-config.rb index 542d67c..12bf118 100644 --- a/lib/pkg-config.rb +++ b/lib/pkg-config.rb @@ -120,11 +120,11 @@ def have_package(pkg, major=nil, minor=0, micro=0) Shellwords.shellwords(libraries)) dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(" ") $libs += " " + libraries - if /mswin/ =~ RUBY_PLATFORM - $DLDFLAGS += " " + dldflags - else - $LDFLAGS += " " + dldflags - end + # mkmf uses $LDFLAGS for both have_func()/try_link() and the + # final link (mswin's Makefile puts $(ldflags) into DLDFLAGS + # too), so /libpath: must go there on mswin as well. With + # $DLDFLAGS only, every link check against the package fails. + $LDFLAGS += " " + dldflags $CFLAGS += " " + cflags_only_other(pkg) if defined?($CXXFLAGS) $CXXFLAGS += " " + cflags_only_other(pkg)