lsh123 / xmlsec

XML Security Library
Other
134 stars 100 forks source link

Unable to link with provided libxslt #839

Closed totszwai closed 2 months ago

totszwai commented 2 months ago

Hello, I am having issues compiling the legacy version against the latest libxslt (1.1.41), it doesn't seem to find the function referrences despite them being there.

Building it with the following:

configure --enable-static --enable-static-linking --disable-mscng --with-pic --disable-crypto-dl --disable-apps-crypto-dl --without-nss --without-gcrypt --without-gnutls

Resulting in errors:

  CCLD     xmlsec1.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: xmlsec.o: in function `xmlSecAppShutdown':
C:/source/windows/xmlsec/src/xmlsec1-1.2.41/apps/xmlsec.c:2546:(.text.startup+0xf0): undefined reference to `__imp_xsltFreeSecurityPrefs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/source/windows/xmlsec/src/xmlsec1-1.2.41/apps/xmlsec.c:2547:(.text.startup+0xf6): undefined reference to `__imp_xsltCleanupGlobals'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: xmlsec.o: in function `xmlSecAppInit':
C:/source/windows/xmlsec/src/xmlsec1-1.2.41/apps/xmlsec.c:2478:(.text.startup+0x900): undefined reference to `__imp_xsltNewSecurityPrefs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/source/windows/xmlsec/src/xmlsec1-1.2.41/apps/xmlsec.c:2479:(.text.startup+0x907): undefined reference to `__imp_xsltSecurityForbid'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/source/windows/xmlsec/src/xmlsec1-1.2.41/apps/xmlsec.c:2479:(.text.startup+0x913): undefined reference to `__imp_xsltSetSecurityPrefs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/source/windows/xmlsec/src/xmlsec1-1.2.41/apps/xmlsec.c:2484:(.text.startup+0x978): undefined reference to `__imp_xsltSetDefaultSecurityPrefs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/et5341/source/windows/xmlsec/src/xmlsec1-1.2.41/src/.libs/libxmlsec1.a(xslt.o): in function `xmlSecXsApplyStylesheet':
C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:531:(.text+0x1b): undefined reference to `__imp_xsltNewTransformContext'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:538:(.text+0x37): undefined reference to `__imp_xsltSetCtxtSecurityPrefs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:544:(.text+0x5b): undefined reference to `__imp_xsltApplyStylesheetUser'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:552:(.text+0x70): undefined reference to `__imp_xsltFreeTransformContext'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/et5341/source/windows/xmlsec/src/xmlsec1-1.2.41/src/.libs/libxmlsec1.a(xslt.o): in function `xmlSecXsltFinalize':
C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:219:(.text+0x2a0): undefined reference to `__imp_xsltFreeStylesheet'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/et5341/source/windows/xmlsec/src/xmlsec1-1.2.41/src/.libs/libxmlsec1.a(xslt.o): in function `xmlSecXsltReadNode':
C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:275:(.text+0x55d): undefined reference to `__imp_xsltParseStylesheetDoc'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/et5341/source/windows/xmlsec/src/xmlsec1-1.2.41/src/.libs/libxmlsec1.a(xslt.o): in function `xmlSecXsltPushBin':
C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:385:(.text+0xace): undefined reference to `__imp_xsltSaveResultTo'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/et5341/source/windows/xmlsec/src/xmlsec1-1.2.41/src/.libs/libxmlsec1.a(xslt.o): in function `xmlSecXslProcess':
C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:492:(.text+0x12f5): undefined reference to `__imp_xsltSaveResultTo'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/et5341/source/windows/xmlsec/src/xmlsec1-1.2.41/src/.libs/libxmlsec1.a(xslt.o): in function `xmlSecTransformXsltInitialize':
C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:118:(.text+0x188a): undefined reference to `__imp_xsltNewSecurityPrefs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:120:(.text+0x18a0): undefined reference to `__imp_xsltSecurityForbid'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:120:(.text+0x18a7): undefined reference to `__imp_xsltSetSecurityPrefs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/et5341/source/windows/xmlsec/src/xmlsec1-1.2.41/src/.libs/libxmlsec1.a(xslt.o): in function `xmlSecTransformXsltShutdown':
C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:129:(.text+0x1962): undefined reference to `__imp_xsltFreeSecurityPrefs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/et5341/source/windows/xmlsec/src/xmlsec1-1.2.41/src/.libs/libxmlsec1.a(xslt.o): in function `xmlSecTransformXsltSetDefaultSecurityPrefs':
C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:147:(.text+0x19a4): undefined reference to `__imp_xsltGetSecurityPrefs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/source/windows/xmlsec/src/xmlsec1-1.2.41/src/xslt.c:147:(.text+0x19b2): undefined reference to `__imp_xsltSetSecurityPrefs'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [Makefile:588: xmlsec1.exe] Error 1
make[2]: Leaving directory '/c/source/windows/xmlsec/src/xmlsec1-1.2.41/apps'
make[1]: *** [Makefile:753: all-recursive] Error 1
make[1]: Leaving directory '/c/source/windows/xmlsec/src/xmlsec1-1.2.41'
make: *** [Makefile:571: all] Error 2

Based on the configure's documentation, if I provide LIBXSLT_CFLAGS and LIBXSLT_LIBS it should be able to sees it, so the values being passed were:

CFLAGS  -O2 -g -DLIBXML_STATIC
LIBXML_CFLAGS  -I/c/Users/et5341/source/windows/libxml2/src/libxml2-2.13.1/include
LIBXML_LIBS  -L/c/Users/et5341/source/windows/libxml2/src/libxml2-2.13.1/.libs -Wl,-R,/c/Users/et5341/source/windows/libxml2/src/libxml2-2.13.1/.libs -lxml2

LIBXSLT_CFLAGS  -I/c/Users/et5341/source/windows/libxslt/src/libxslt-1.1.41
LIBXSLT_LIBS  -L/c/Users/et5341/source/windows/libxslt/src/libxslt-1.1.41/libxslt/.libs -Wl,-R,/c/Users/et5341/source/windows/libxslt/src/libxslt-1.1.41/libxslt/.libs -lxslt

OPENSSL_CFLAGS  -I/c/Users/et5341/source/windows/openssl/src/openssl-1.1.1v/include
OPENSSL_LIBS  -L/c/Users/et5341/source/windows/openssl/src/openssl-1.1.1v -Wl,-R,/c/Users/et5341/source/windows/openssl/src/openssl-1.1.1v -lssl -lcrypto

The provided location did contains all the libs:

et5341@CIS074 MINGW64 ~/source/windows/libxslt/src/libxslt-1.1.41/libxslt/.libs
$ ls -rtl
total 4268
-rw-r--r-- 1 et5341 Domain Users  168548 Aug 28 12:06 libxslt.dll.a
-rwxr-xr-x 1 et5341 Domain Users 1508288 Aug 28 12:06 libxslt-1.dll
-rw-r--r-- 1 et5341 Domain Users 1326278 Aug 28 12:06 libxslt.a
-rw-r--r-- 1 et5341 Domain Users    1122 Aug 28 12:06 libxslt.la
-rw-r--r-- 1 et5341 Domain Users    1070 Aug 28 12:06 libxslt.lai

And they do contains the functions:

et5341@CIS074 MINGW64 ~/source/windows/libxslt/src/libxslt-1.1.41/libxslt/.libs
$ grep -r xsltFreeSecurityPrefs *
Binary file libxslt-1.dll matches
Binary file libxslt.a matches
Binary file libxslt.dll.a matches
Binary file security.o matches
totszwai commented 2 months ago

Looks like I needed to include -DLIBXSLT_STATIC

https://github.com/msys2/MINGW-packages/issues/4528#issuecomment-429330012