Skip to content

Windows build fails with MSVC due to mixed CRT (/MT vs /MD) between project and dependencies #26

@Steven4565

Description

@Steven4565

Description

When building on Windows with MSVC, the project fails to link because of a runtime library mismatch between the top-level server.obj and the llama.lib dependency:

llama.lib(llama.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in server.obj

This happens because the CMakeLists.txt calls:

include(${CMAKE_SOURCE_DIR}/cmake/ucm.cmake)
ucm_set_runtime(STATIC)

which forces /MT (static CRT).

Some dependencies (like llama.cpp via inference/) are built with /MD (dynamic CRT), which is the default for vcpkg’s x64-windows triplet.

The following flags can be used to force CMake to use dynamic CRT.

-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL ^
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW

Steps to Reproduce

Install Dependencies

  • Run git clone https://github.com/kolosalai/kolosal-server.git --recurisve
  • Run cd kolosal-server
  • Make a vcpkg.json file at the root of the project
    {
      "name": "kolosal-server",
      "version-string": "1.0.0",
      "dependencies": [
        "curl",
        "fontconfig",
        "freetype",
        "libjpeg-turbo",
        "libpng",
        "openssl",
        "libxml2",
        "tiff",
        "zlib",
        "openblas",
        "lapack-reference"
      ]
    }
    
  • Run mkdir build && cd build
  • Run
    cmake -S . -B build -G "Visual Studio 17 2022" -A x64 ^
    -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake"
    
  • Run cd .. && cmake --build build --config Release --target kolosal_server_exe

Environment

OS: Windows 11 26100.4946
Build tool: Visual Studio 17 2022
Built on commit: 5e4fb47f7b87040ecae74d52f17a010ecf73609f

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions