From eeffe2edc2fbb49fd7ca23deea147df93681f0a1 Mon Sep 17 00:00:00 2001 From: Trevor SANDY Date: Wed, 26 Nov 2025 01:39:45 +0100 Subject: [PATCH 1/2] docs: build llama.cpp using MSVC - Visual Studio 17 2022 Added detailed instructions for building libcurl and ccache dependencies. --- docs/build.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/docs/build.md b/docs/build.md index 7d244ff013..8c2f62242c 100644 --- a/docs/build.md +++ b/docs/build.md @@ -69,6 +69,48 @@ cmake --build build --config Release - **Debian / Ubuntu:** `sudo apt-get install libcurl4-openssl-dev` # (or `libcurl4-gnutls-dev` if you prefer GnuTLS) - **Fedora / RHEL / Rocky / Alma:** `sudo dnf install libcurl-devel` - **Arch / Manjaro:** `sudo pacman -S curl` # includes libcurl headers +- Build llama.cpp using MSVC _19.44.35219.0_ - Visual Studio 17 2022: + - Install development instance of _libcurl_. + ```bat + git clone https://github.com/microsoft/vcpkg.git + cd vcpkg + bootstrap-vcpkg.bat + vcpkg.exe install curl:x64-windows --vcpkg-root %cd% --disable-metrics + cd .. + ``` + - Build _ccache_ executable - optional. + ```bat + git clone https://github.com/ccache/ccache.git + cd ccache + cmake -B build -DCMAKE_BUILD_TYPE=Release + cmake --build build --config Release -j 4 + cd .. + ``` + - To suppress warnings, add the following to `if (MSVC)...` in the top-level _CMakeLists.txt_. + ```cmake + add_compile_options( + /wd4101 # unreferenced local variable + /wd4244 # conversion from 'type1' to 'type2', possible loss of data + /wd4267 # conversion from 'size_t' to a smaller type, possible loss of data + /wd4305 # truncation from 'type1' to 'type2' + /wd4319 # zero extending 'uint32_t' to 'size_t' of greater size + /wd4804 # unsafe use of type 'bool' + /wd4996 # the POSIX name for this item is deprecated + ) + ``` + - Build configuration - release build with build shared libs disabled. + ```bat + :: Use full file paths for libcurl and ccache. Replace with valid user ID if applicable. + cmake -B build -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release ^ + -DCURL_LIBRARY=C:\Users\\Projects\llama.cpp\vcpkg\packages\curl_x64-windows\lib\libcurl.lib ^ + -DCURL_INCLUDE_DIR=C:\Users\\Projects\llama.cpp\vcpkg\packages\curl_x64-windows\include ^ + -DCMAKE_C_COMPILER_LAUNCHER=C:\Users\\Projects\llama.cpp\ccache\build\Release\ccache.exe ^ + -DCMAKE_CXX_COMPILER_LAUNCHER=C:\Users\\Projects\llama.cpp\ccache\build\Release\ccache.exe + ``` + - Build + ```bat + cmake --build build --config Release -j 8 + ``` ## BLAS Build From ddf51c1f7d95113c94a3aabf2cfb475e5238c396 Mon Sep 17 00:00:00 2001 From: Trevor SANDY Date: Wed, 26 Nov 2025 23:15:34 +0100 Subject: [PATCH 2/2] docs: extend Windows cmake build options and add Pack and Run --- docs/build.md | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/docs/build.md b/docs/build.md index 8c2f62242c..6cde84b9ab 100644 --- a/docs/build.md +++ b/docs/build.md @@ -86,7 +86,7 @@ cmake --build build --config Release cmake --build build --config Release -j 4 cd .. ``` - - To suppress warnings, add the following to `if (MSVC)...` in the top-level _CMakeLists.txt_. + - To suppress warnings, add the following to `if (MSVC)`... in the top-level _CMakeLists.txt_. ```cmake add_compile_options( /wd4101 # unreferenced local variable @@ -94,22 +94,43 @@ cmake --build build --config Release /wd4267 # conversion from 'size_t' to a smaller type, possible loss of data /wd4305 # truncation from 'type1' to 'type2' /wd4319 # zero extending 'uint32_t' to 'size_t' of greater size + /wd4334 # result of 32-bit shift implicitly converted to 64 bits /wd4804 # unsafe use of type 'bool' /wd4996 # the POSIX name for this item is deprecated ) ``` - - Build configuration - release build with build shared libs disabled. + - Build configuration - windows-cpu release build with shared libs enabled. ```bat - :: Use full file paths for libcurl and ccache. Replace with valid user ID if applicable. - cmake -B build -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release ^ - -DCURL_LIBRARY=C:\Users\\Projects\llama.cpp\vcpkg\packages\curl_x64-windows\lib\libcurl.lib ^ - -DCURL_INCLUDE_DIR=C:\Users\\Projects\llama.cpp\vcpkg\packages\curl_x64-windows\include ^ - -DCMAKE_C_COMPILER_LAUNCHER=C:\Users\\Projects\llama.cpp\ccache\build\Release\ccache.exe ^ - -DCMAKE_CXX_COMPILER_LAUNCHER=C:\Users\\Projects\llama.cpp\ccache\build\Release\ccache.exe + :: Use full file paths for libcurl and ccache. + SET CURL_PATH=%USERPROFILE%\Projects\llama.cpp\vcpkg\packages\curl_x64-windows + SET CCACHE_PATH=%USERPROFILE%\Projects\llama.cpp\ccache\build\Release + cmake -S . -B build -G "Visual Studio 17 2022" ^ + -DBUILD_SHARED_LIBS=ON ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DGGML_NATIVE=OFF ^ + -DGGML_BACKEND_DL=ON ^ + -DGGML_CPU_ALL_VARIANTS=ON ^ + -DGGML_OPENMP=ON ^ + -DCURL_LIBRARY=%CURL_PATH%\lib\libcurl.lib ^ + -DCURL_INCLUDE_DIR=%CURL_PATH%\include ^ + -DCMAKE_C_COMPILER_LAUNCHER=%CCACHE_PATH%\ccache.exe ^ + -DCMAKE_CXX_COMPILER_LAUNCHER=%CCACHE_PATH%\ccache.exe ``` - Build ```bat - cmake --build build --config Release -j 8 + cmake --build build --config Release + ``` + - Pack + ```bat + copy %CURL_PATH%\bin\libcurl.dll build\bin\Release + :: Use qualified 7zip path if not in PATH - e.g. vcpkg\downloads\tools\7zip-25.01-windows\7z + \7z a llama-bin-win-cpu-x64.zip build\bin\Release\* + ``` + - Run WebUI + ```bat + cd build\bin\Release + :: local HTTP server accessed via browser: http://localhost:8080 + llama-server -hf ggml-org/gemma-3-1b-it-GGUF ``` ## BLAS Build