Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QT 5.15.2 Static Build MSVC2019 x86 OpenSSL Windows 10 Link 'ucrtd.lib' Error



  • I have been attempting to compile a static build for a few days and finally got it to compile correctly but the linking is incorrect in Qt Creator? I'm trying to static link Openssl, it's was also compiled MSVC2019 x86. What steps am I missing, It seems the CMake is incorrect?

    QTCreator 5.0.1

    Build Target: x86

    Target Windows SDK: 10.0.20348.0

    My Native Tools Command Prompt

    %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 10.0.20348.0
    

    Config for x86 MSVC2019:

    configure -release -nomake examples -nomake tests -opensource -confirm-license -platform win32-msvc2019 -static -static-runtime -prefix "C:\Qt\5.15.2\Static" -openssl -openssl-linked OPENSSL_INCDIR="C:\Program Files (x86)\OpenSSL\include" OPENSSL_LIBDIR="C:\Program Files (x86)\OpenSSL\lib" OPENSSL_LIBS="-llibssl -llibcrypto"
    

    My error in QTCreator 5.0.1:

    C:\Qt\Tools\CMake_64\share\cmake-3.21\Modules\CMakeTestCXXCompiler.cmake:62: error: The C++ compiler "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/HostX86/x86/cl.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: C:/Users/Ponzi/Documents/build-Example-Clone_of_Desktop_x86_windows_msvc2019_pe_32bit-Debug/CMakeFiles/CMakeTmp Run Build Command(s):C:/Ninja/ninja.exe cmTC_5ba96 && [1/2] Building CXX object CMakeFiles\cmTC_5ba96.dir\testCXXCompiler.cxx.obj [2/2] Linking CXX executable cmTC_5ba96.exe FAILED: cmTC_5ba96.exe cmd.exe /C "cd . && C:\Qt\Tools\CMake_64\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_5ba96.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100203~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100203~1.0\x86\mt.exe --manifests  -- C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx86\x86\link.exe /nologo CMakeFiles\cmTC_5ba96.dir\testCXXCompiler.cxx.obj  /out:cmTC_5ba96.exe /implib:cmTC_5ba96.lib /pdb:cmTC_5ba96.pdb /version:0.0 /machine:X86  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ." LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx86\x86\link.exe /nologo CMakeFiles\cmTC_5ba96.dir\testCXXCompiler.cxx.obj /out:cmTC_5ba96.exe /implib:cmTC_5ba96.lib /pdb:cmTC_5ba96.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_5ba96.dir/intermediate.manifest CMakeFiles\cmTC_5ba96.dir/manifest.res" failed (exit code 1104) with the following output: LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' ninja: build stopped: subcommand failed.
    

    CMakeError.log

    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
    Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/HostX86/x86/cl.exe 
    Build flags: 
    Id flags:  
    
    The output was:
    2
    Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30133 for x86
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    CMakeCXXCompilerId.cpp
    Microsoft (R) Incremental Linker Version 14.29.30133.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    /out:CMakeCXXCompilerId.exe 
    CMakeCXXCompilerId.obj 
    LINK : fatal error LNK1104: cannot open file 'libucrt.lib'
    
    
    Detecting CXX compiler ABI info failed to compile with the following output:
    Change Dir: C:/Users/Ponzi/Documents/build-Example-Clone_of_Desktop_x86_windows_msvc2019_pe_32bit-Debug/CMakeFiles/CMakeTmp
    
    Run Build Command(s):C:/Ninja/ninja.exe cmTC_7b937 && [1/2] Building CXX object CMakeFiles\cmTC_7b937.dir\CMakeCXXCompilerABI.cpp.obj
    
    [2/2] Linking CXX executable cmTC_7b937.exe
    
    FAILED: cmTC_7b937.exe 
    
    cmd.exe /C "cd . && C:\Qt\Tools\CMake_64\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_7b937.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100203~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100203~1.0\x86\mt.exe --manifests  -- C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx86\x86\link.exe /nologo CMakeFiles\cmTC_7b937.dir\CMakeCXXCompilerABI.cpp.obj  /out:cmTC_7b937.exe /implib:cmTC_7b937.lib /pdb:cmTC_7b937.pdb /version:0.0 /machine:X86  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
    
    LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx86\x86\link.exe /nologo CMakeFiles\cmTC_7b937.dir\CMakeCXXCompilerABI.cpp.obj /out:cmTC_7b937.exe /implib:cmTC_7b937.lib /pdb:cmTC_7b937.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_7b937.dir/intermediate.manifest CMakeFiles\cmTC_7b937.dir/manifest.res" failed (exit code 1104) with the following output:
    LINK : fatal error LNK1104: cannot open file 'ucrtd.lib'
    
    ninja: build stopped: subcommand failed.
    
    
    Determining if the CXX compiler works failed with the following output:
    Change Dir: C:/Users/Ponzi/Documents/build-Example-Clone_of_Desktop_x86_windows_msvc2019_pe_32bit-Debug/CMakeFiles/CMakeTmp
    
    Run Build Command(s):C:/Ninja/ninja.exe cmTC_5ba96 && [1/2] Building CXX object CMakeFiles\cmTC_5ba96.dir\testCXXCompiler.cxx.obj
    
    [2/2] Linking CXX executable cmTC_5ba96.exe
    
    FAILED: cmTC_5ba96.exe 
    
    cmd.exe /C "cd . && C:\Qt\Tools\CMake_64\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_5ba96.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100203~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100203~1.0\x86\mt.exe --manifests  -- C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx86\x86\link.exe /nologo CMakeFiles\cmTC_5ba96.dir\testCXXCompiler.cxx.obj  /out:cmTC_5ba96.exe /implib:cmTC_5ba96.lib /pdb:cmTC_5ba96.pdb /version:0.0 /machine:X86  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
    
    LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx86\x86\link.exe /nologo CMakeFiles\cmTC_5ba96.dir\testCXXCompiler.cxx.obj /out:cmTC_5ba96.exe /implib:cmTC_5ba96.lib /pdb:cmTC_5ba96.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_5ba96.dir/intermediate.manifest CMakeFiles\cmTC_5ba96.dir/manifest.res" failed (exit code 1104) with the following output:
    LINK : fatal error LNK1104: cannot open file 'ucrtd.lib'
    
    ninja: build stopped: subcommand failed.
    

    CMakeOutput.log

    The system is: Windows - 10.0.19043 - AMD64
    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
    Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/HostX86/x86/cl.exe 
    Build flags: 
    Id flags: -c 
    
    The output was:
    0
    Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30133 for x86
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    CMakeCXXCompilerId.cpp
    
    
    Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.obj"
    
    The CXX compiler identification is MSVC, found in "C:/Users/Ponzi/Documents/build-Example-Clone_of_Desktop_x86_windows_msvc2019_pe_32bit-Debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.obj"
    


  • Hi, I think the problem is in the last part of your configure command:
    ....OPENSSL_LIBS="-llibssl -llibcrypto"
    those .libs are probably the default vanilla build, which means they expect the MSVC2019 runtime to be loaded dynamically, not static.

    Instead of using the default .SLL library, try for example Shining Light Productions full version:
    https://slproweb.com/download/Win32OpenSSL-1_1_1L.exe
    and the static /MT versions of the libs.

    Change that last part of your configure command to:
    ....OPENSSL_LIBS="-lVC\static\libssl32MT -lVC\static\libcrypto32MT"

    (You might also need to change your OPENSSL_LIBDIR prefix:
    .. OPENSSL_LIBDIR="C:\Program Files (x86)\OpenSSL\lib" ...
    to where you install the Shining Light library.)


Log in to reply