strawberrymusicplayer / strawberry-msvc

:strawberry: Instructions and batch files for building Strawberry with Visual Studio 2022
https://www.strawberrymusicplayer.org/
9 stars 2 forks source link

Cannot build libxml2 #5

Closed Erriez closed 1 month ago

Erriez commented 1 month ago

Started from Visual Studio 2022 x64 Native Tools Command Prompt on Windows 11:

cd C:\data\projects\strawberry\strawberry-msvc 

git log
commit ea0c4c786691ffd410cd98e248e84f2ba75e7ac5 (HEAD -> master, origin/master, origin/HEAD)
Date:   Sun Oct 27 01:33:33 2024 +0200

git status
no changes

Build started from empty directories:
- C:\strawberry_msvc_x86_64_release
- C:\data\projects\strawberry\msvc_\build_release

.\build.bat release
...
-- The C compiler identification is MSVC 19.41.34123.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: C:/strawberry_msvc_x86_64_release/bin/pkg-config.exe (found version "2.3.0")
-- Found Iconv: C:/strawberry_msvc_x86_64_release/lib/libiconv.lib (found version "1.17")
-- Found the following ICU libraries:
--   data (required): C:/strawberry_msvc_x86_64_release/lib/icudt.lib
--   i18n (required): C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64/icuin.Lib
--   uc (required): C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64/icuuc.lib
-- Found ICU: C:/strawberry_msvc_x86_64_release/include (found version "76.1")
-- Looking for lzma_auto_decoder in C:/strawberry_msvc_x86_64_release/lib/lzma.lib
-- Looking for lzma_auto_decoder in C:/strawberry_msvc_x86_64_release/lib/lzma.lib - found
-- Looking for lzma_easy_encoder in C:/strawberry_msvc_x86_64_release/lib/lzma.lib
-- Looking for lzma_easy_encoder in C:/strawberry_msvc_x86_64_release/lib/lzma.lib - found
-- Looking for lzma_lzma_preset in C:/strawberry_msvc_x86_64_release/lib/lzma.lib
-- Looking for lzma_lzma_preset in C:/strawberry_msvc_x86_64_release/lib/lzma.lib - found
-- Found LibLZMA: C:/strawberry_msvc_x86_64_release/lib/lzma.lib (found version "5.6.3")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Found ZLIB: C:/strawberry_msvc_x86_64_release/lib/z.lib (found version "1.3.1")
-- Checking for module 'icu-i18n'
--   Found icu-i18n, version 76.1
-- Checking for module 'liblzma'
--   Found liblzma, version 5.6.3
-- Checking for module 'zlib'
--   Found zlib, version 1.3.1
-- Configuring done (6.1s)
-- Generating done (0.2s)
-- Build files have been written to: C:/data/projects/strawberry/msvc_/build_release/libxml2-v2.13.4/build
[  1%] Building C object CMakeFiles/LibXml2.dir/buf.c.obj
buf.c
[  2%] Building C object CMakeFiles/LibXml2.dir/c14n.c.obj
c14n.c
[  4%] Building C object CMakeFiles/LibXml2.dir/catalog.c.obj
catalog.c
[  5%] Building C object CMakeFiles/LibXml2.dir/chvalid.c.obj
chvalid.c
[  6%] Building C object CMakeFiles/LibXml2.dir/debugXML.c.obj
debugXML.c
[  8%] Building C object CMakeFiles/LibXml2.dir/dict.c.obj
dict.c
[  9%] Building C object CMakeFiles/LibXml2.dir/encoding.c.obj
encoding.c
[ 11%] Building C object CMakeFiles/LibXml2.dir/entities.c.obj
entities.c
[ 12%] Building C object CMakeFiles/LibXml2.dir/error.c.obj
error.c
[ 13%] Building C object CMakeFiles/LibXml2.dir/globals.c.obj
globals.c
[ 15%] Building C object CMakeFiles/LibXml2.dir/hash.c.obj
hash.c
[ 16%] Building C object CMakeFiles/LibXml2.dir/HTMLparser.c.obj
HTMLparser.c
[ 18%] Building C object CMakeFiles/LibXml2.dir/HTMLtree.c.obj
HTMLtree.c
[ 19%] Building C object CMakeFiles/LibXml2.dir/legacy.c.obj
legacy.c
[ 20%] Building C object CMakeFiles/LibXml2.dir/list.c.obj
list.c
[ 22%] Building C object CMakeFiles/LibXml2.dir/nanoftp.c.obj
nanoftp.c
[ 23%] Building C object CMakeFiles/LibXml2.dir/nanohttp.c.obj
nanohttp.c
[ 25%] Building C object CMakeFiles/LibXml2.dir/parser.c.obj
parser.c
[ 26%] Building C object CMakeFiles/LibXml2.dir/parserInternals.c.obj
parserInternals.c
[ 27%] Building C object CMakeFiles/LibXml2.dir/pattern.c.obj
pattern.c
[ 29%] Building C object CMakeFiles/LibXml2.dir/relaxng.c.obj
relaxng.c
[ 30%] Building C object CMakeFiles/LibXml2.dir/SAX.c.obj
SAX.c
[ 31%] Building C object CMakeFiles/LibXml2.dir/SAX2.c.obj
SAX2.c
[ 33%] Building C object CMakeFiles/LibXml2.dir/schematron.c.obj
schematron.c
[ 34%] Building C object CMakeFiles/LibXml2.dir/threads.c.obj
threads.c
[ 36%] Building C object CMakeFiles/LibXml2.dir/tree.c.obj
tree.c
[ 37%] Building C object CMakeFiles/LibXml2.dir/uri.c.obj
uri.c
[ 38%] Building C object CMakeFiles/LibXml2.dir/valid.c.obj
valid.c
[ 40%] Building C object CMakeFiles/LibXml2.dir/xinclude.c.obj
xinclude.c
[ 41%] Building C object CMakeFiles/LibXml2.dir/xlink.c.obj
xlink.c
[ 43%] Building C object CMakeFiles/LibXml2.dir/xmlIO.c.obj
xmlIO.c
[ 44%] Building C object CMakeFiles/LibXml2.dir/xmlmemory.c.obj
xmlmemory.c
[ 45%] Building C object CMakeFiles/LibXml2.dir/xmlmodule.c.obj
xmlmodule.c
[ 47%] Building C object CMakeFiles/LibXml2.dir/xmlreader.c.obj
xmlreader.c
[ 48%] Building C object CMakeFiles/LibXml2.dir/xmlregexp.c.obj
xmlregexp.c
[ 50%] Building C object CMakeFiles/LibXml2.dir/xmlsave.c.obj
xmlsave.c
[ 51%] Building C object CMakeFiles/LibXml2.dir/xmlschemas.c.obj
xmlschemas.c
[ 52%] Building C object CMakeFiles/LibXml2.dir/xmlschemastypes.c.obj
xmlschemastypes.c
[ 54%] Building C object CMakeFiles/LibXml2.dir/xmlstring.c.obj
xmlstring.c
[ 55%] Building C object CMakeFiles/LibXml2.dir/xmlunicode.c.obj
xmlunicode.c
[ 56%] Building C object CMakeFiles/LibXml2.dir/xmlwriter.c.obj
xmlwriter.c
[ 58%] Building C object CMakeFiles/LibXml2.dir/xpath.c.obj
xpath.c
[ 59%] Building C object CMakeFiles/LibXml2.dir/xpointer.c.obj
xpointer.c
[ 61%] Building C object CMakeFiles/LibXml2.dir/xzlib.c.obj
xzlib.c
[ 62%] Building RC object CMakeFiles/LibXml2.dir/win32/libxml2.rc.res
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.

[ 63%] Linking C shared library libxml2.dll
LINK: command "C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\LibXml2.dir\objects1.rsp /out:libxml2.dll /implib:libxml2.lib /pdb:C:\data\projects\strawberry\msvc_\build_release\libxml2-v2.13.4\build\libxml2.pdb /dll /version:2.13 /machine:x64 /INCREMENTAL:NO ws2_32.lib bcrypt.lib C:\strawberry_msvc_x86_64_release\lib\icudt.lib C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\icuin.Lib C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\icuuc.lib C:\strawberry_msvc_x86_64_release\lib\lzma.lib C:\strawberry_msvc_x86_64_release\lib\z.lib C:\strawberry_msvc_x86_64_release\lib\libiconv.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=2" failed (exit code 1120) with the following output:
   Creating library libxml2.lib and object libxml2.exp
encoding.c.obj : error LNK2019: unresolved external symbol UCNV_FROM_U_CALLBACK_STOP_76 referenced in function openIcuConverter
encoding.c.obj : error LNK2019: unresolved external symbol UCNV_TO_U_CALLBACK_STOP_76 referenced in function openIcuConverter
encoding.c.obj : error LNK2019: unresolved external symbol ucnv_open_76 referenced in function openIcuConverter
encoding.c.obj : error LNK2019: unresolved external symbol ucnv_close_76 referenced in function closeIcuConverter
encoding.c.obj : error LNK2019: unresolved external symbol ucnv_setToUCallBack_76 referenced in function openIcuConverter
encoding.c.obj : error LNK2019: unresolved external symbol ucnv_setFromUCallBack_76 referenced in function openIcuConverter
encoding.c.obj : error LNK2019: unresolved external symbol ucnv_convertEx_76 referenced in function xmlCharEncInput
libxml2.dll : fatal error LNK1120: 7 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_dll --intdir=CMakeFiles\LibXml2.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests -- C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\LibXml2.dir\objects1.rsp @C:\Users\user\AppData\Local\Temp\nm1254.tmp' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\nmake.exe" -s -f CMakeFiles\LibXml2.dir\build.make /nologo -SL                 CMakeFiles\LibXml2.dir\build' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\nmake.exe" -s -f CMakeFiles\Makefile2 /nologo -LS                 all' : return code '0x2'
Stop.

Any suggestion?

jonaski commented 1 month ago

You are linking to the wrong ICU:

These should not be there: C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\icuin.Lib C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\icuuc.lib

Erriez commented 1 month ago

These should not be there: C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\icuin.Lib C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\icuuc.lib

Thanks for your useful hint, you're right!

C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\ is automatically created by installing Microsoft Visual Studio 2022 Community edition Desktop development with C++ | Windows 11 SDK. This component is required, otherwise build errors occurs:

image

image

Removing the Windows Performance Toolkit deletes C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\, but cannot build libxml2 anymore:

c:\data\projects\strawberry\msvc_\build_release>cd "libxml2-v2.13.4"   || goto end

c:\data\projects\strawberry\msvc_\build_release\libxml2-v2.13.4>if not exist build mkdir build   || goto end

c:\data\projects\strawberry\msvc_\build_release\libxml2-v2.13.4>cmake --log-level="DEBUG" -S . -B build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="c:/strawberry_msvc_x86_64_release" -DBUILD_SHARED_LIBS=ON -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_ZLIB=ON -DLIBXML2_WITH_LZMA=ON -DLIBXML2_WITH_ICONV=ON -DLIBXML2_WITH_ICU=ON   || goto end
-- The C compiler identification is MSVC 19.41.34123.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: 'C:/data/projects/strawberry/msvc_/build_release/libxml2-v2.13.4/build/CMakeFiles/CMakeScratch/TryCompile-yj85lg'

    Run Build Command(s): "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/cmake.exe" -E env VERBOSE=1 nmake -f Makefile /nologo cmTC_99cde\fast
        "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\nmake.exe"  -f CMakeFiles\cmTC_99cde.dir\build.make /nologo -L                  CMakeFiles\cmTC_99cde.dir\build
    Building C object CMakeFiles/cmTC_99cde.dir/testCCompiler.c.obj
        "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E cmake_cl_compile_depends --dep-file=CMakeFiles\cmTC_99cde.dir\testCCompiler.c.obj.d --working-dir=C:\data\projects\strawberry\msvc_\build_release\libxml2-v2.13.4\build\CMakeFiles\CMakeScratch\TryCompile-yj85lg --filter-prefix="Note: including file: " -- C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\cl.exe @C:\Users\user\AppData\Local\Temp\nmB569.tmp
    testCCompiler.c
    Linking C executable cmTC_99cde.exe
        "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_99cde.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_99cde.dir\objects1.rsp @C:\Users\user\AppData\Local\Temp\nmB5B8.tmp
    Visual Studio Incremental Link with embedded manifests
    Create CMakeFiles\cmTC_99cde.dir/manifest.rc
    Create empty: CMakeFiles\cmTC_99cde.dir/embed.manifest
    RC Pass 1:
    rc /fo CMakeFiles\cmTC_99cde.dir/manifest.res CMakeFiles\cmTC_99cde.dir/manifest.rc
    RC Pass 1: command "rc /fo CMakeFiles\cmTC_99cde.dir/manifest.res CMakeFiles\cmTC_99cde.dir/manifest.rc" failed (exit code 0) with the following output:
    no such file or directoryNMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_99cde.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_99cde.dir\objects1.rsp @C:\Users\user\AppData\Local\Temp\nmB5B8.tmp' : return code '0xffffffff'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\nmake.exe"  -f CMakeFiles\cmTC_99cde.dir\build.make /nologo -L                  CMakeFiles\cmTC_99cde.dir\build' : return code '0x2'
    Stop.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:13 (project)

-- Configuring incomplete, errors occurred!

Quickest workaround is to rename the files as you mentioned, then the build and link of libxml2 is successful:

I've no better workaround in mind. I assume every developer building Strawberry on a Windows (11) desktop with Visual Studio 2022 will encounter this.

Something to mention to the README.md?

jonaski commented 1 month ago

Adding -DICU_ROOT="%PREFIX_PATH_FORWARD%" to the CMake command for libxml2 fixes this, however the safest is probably renaming the conflicting icu in Windows Kits to make sure it doesn't use any of those headers or libraries.

Erriez commented 1 month ago

Thank you very much. I've tested your suggestion and solves the issue. I was already creating a PR for you, but now I see you've already fixed it. đź‘Ť