https://bugs.openldap.org/show_bug.cgi?id=9226
Bug ID: 9226 Summary: MinGW build fails to link rewrite program with --enable-dynamic Product: OpenLDAP Version: 2.5 Hardware: All OS: All Status: UNCONFIRMED Severity: normal Priority: --- Component: build Assignee: bugs@openldap.org Reporter: ryan@openldap.org Target Milestone: ---
/bin/sh ../../libtool --mode=link cc -g -O2 -o rewrite rewrite.o parse.o librewrite.a ../../libraries/libldap_r/libldap_r.la ../../libraries/liblber/liblber.la ../../libraries/liblutil/liblutil.a -lregex -lws2_32 libtool: link: cc -g -O2 -o .libs/rewrite rewrite.o parse.o librewrite.a ../../libraries/libldap_r/.libs/libldap_r.dll.a /home/ryan/openldap/libraries/liblber/.libs/liblber.dll.a ../../libraries/liblber/.libs/liblber.dll.a ../../libraries/liblutil/liblutil.a -lregex -lws2_32 -L/mingw64/lib C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../../libraries/liblutil/liblutil.a(utils.o): in function `lutil_str2bin': C:\msys64\home\ryan\openldap\libraries\liblutil/utils.c:933: undefined reference to `__imp_ber_memfree_x' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\home\ryan\openldap\libraries\liblutil/utils.c:887: undefined reference to `__imp_ber_memalloc_x' collect2.exe: error: ld returned 1 exit status make[2]: *** [Makefile:292: rewrite] Error 1
I think this is caused by the order of libraries on the link line. MinGW's import libraries (.dll.a) behave like static libraries with one .o per function, so liblutil.a should come before liblber.dll.a. I guess it doesn't occur on UNIX because the shared libraries are scanned differently. It doesn't occur with static linking because entire objects are linked and liblber.a/memory.o is already pulled in by libldap.
N.B.: RE24 with --enable-dynamic fails to link liblber; the error looks superficially similar but it is not the same. RE24's issue is a libtool bug, already fixed in master by upgrading libtool.
https://bugs.openldap.org/show_bug.cgi?id=9226
Ryan Tandy ryan@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |IN_PROGRESS
https://bugs.openldap.org/show_bug.cgi?id=9226
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |TEST Target Milestone|--- |2.5.0 Status|IN_PROGRESS |RESOLVED
--- Comment #1 from Quanah Gibson-Mount quanah@openldap.org --- • db404baf by Ryan Tandy at 2020-04-16T19:35:53-07:00 ITS#9226 Fix link order for rewrite program on MinGW
https://bugs.openldap.org/show_bug.cgi?id=9226
Ryan Tandy ryan@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.openldap.org/s | |how_bug.cgi?id=6517
https://bugs.openldap.org/show_bug.cgi?id=9226
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|TEST |FIXED Status|RESOLVED |VERIFIED