This is a good idea. Plain `LDADD` (not `LIBADD`) is used to add libraries to all programs in current Makefile.am.
I have attached updated patch. - Kirill Makurin ________________________________ From: LIU Hao Sent: Tuesday, June 3, 2025 12:47 PM To: mingw-w64-public@lists.sourceforge.net; Kirill Makurin Subject: Re: [Mingw-w64-public] winpthreads: make testing shared library work 在 2025-6-1 15:06, Kirill Makurin 写道: > diff --git a/mingw-w64-libraries/winpthreads/tests/Makefile.am > b/mingw-w64-libraries/winpthreads/tests/Makefile.am > index 9dda82f73..74549952d 100644 > --- a/mingw-w64-libraries/winpthreads/tests/Makefile.am > +++ b/mingw-w64-libraries/winpthreads/tests/Makefile.am > @@ -5,9 +5,13 @@ if !MSVC > AM_LDFLAGS += -L$(top_builddir)/fakelib > endif > > -AM_LDFLAGS += -L$(top_builddir) -lwinpthread -static > +AM_LDFLAGS += -L$(top_builddir) -lwinpthread Yes this use of `-lwinpthread` seems incorrect, because of the reason you've pointed out. This seems a good reason to apply `*_LDADD = $(top_builddir)/libwinpthread.la` to every test program; however instead of doing that for each target, it's possible to apply it globally by default: LIBADD = $(top_builddir)/libwinpthread.la can you try that? -- Best regards, LIU Hao
From 2347a4099e1340a2789ac9f11001c25548463e69 Mon Sep 17 00:00:00 2001 From: Kirill Makurin <maiddais...@outlook.com> Date: Tue, 3 Jun 2025 18:34:24 +0900 Subject: [PATCH] winpthreads: make testing shared library work Running `make check` when configured with `--disable-static`, depending on whether an installed winpthread library can be found when linking tests, has the following consequences: If an installed winpthread library is found, tests will be linked against installed library instead of the one we just built. If there is no installed winpthread library, tests will be linked against shared library. This will result in tests failing, since they will fail to locate just built DLL at runtime. To fix this: Use `libtool --mode=execute` to run tests. Libtool will handle runtime search path. Remove `-static` from `AM_LDFLAGS`, so we can link against the DLL. During link, pass libwinpthread.la instead of `-lwinpthread`. This will prevent libtool from linking against an installed winpthread library. Signed-off-by: Kirill Makurin <maiddais...@outlook.com> --- mingw-w64-libraries/winpthreads/tests/Makefile.am | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mingw-w64-libraries/winpthreads/tests/Makefile.am b/mingw-w64-libraries/winpthreads/tests/Makefile.am index 9dda82f73..ae3380f61 100644 --- a/mingw-w64-libraries/winpthreads/tests/Makefile.am +++ b/mingw-w64-libraries/winpthreads/tests/Makefile.am @@ -1,13 +1,17 @@ +# Make sure we use "libtool --mode=execute" to run tests, so they can find +# just built winpthread DLL at runtime. +LOG_COMPILER = $(top_builddir)/libtool +AM_LOG_FLAGS = --mode=execute + AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include -AM_LDFLAGS = +AM_LDFLAGS = -L$(top_builddir) if !MSVC AM_LDFLAGS += -L$(top_builddir)/fakelib endif -AM_LDFLAGS += -L$(top_builddir) -lwinpthread -static +LDADD = $(top_builddir)/libwinpthread.la #FIXME: The test "test.c" is inherently broken currently. check_PROGRAMS = t_clock_getres t_clock_gettime t_clock_nanosleep t_clock_settime t_nanosleep #test TESTS = $(check_PROGRAMS) - -- 2.46.1.windows.1
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public