2

I am trying to write a simple application that uses llama.cpp and I am including it to my application using cmake and vcpkg.

My CMakeList.txt is:

cmake_minimum_required(VERSION 4.0)
if(WIN32)
    File(TO_CMAKE_PATH $ENV{VCPKG_ROOT} VCPKG_ROOT)
    message(STATUS ${VCPKG_ROOT})
    set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
    set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "")
else(WIN32)
    if(NOT DEFINED ENV{VCPKG_ROOT})
        message(WARNING "Please set VCPKG_ROOT to the root of the vcpkg installation.")
    endif()
    file(TO_CMAKE_PATH $ENV{VCPKG_ROOT} VCPKG_ROOT)
    message(STATUS ${VCPKG_ROOT})
    set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "" FORCE)
    set(VCPKG_TARGET_TRIPLET "x64-linux" CACHE STRING "")
endif(WIN32)
project(MyLlamaApp)

set(CMAKE_CXX_STANDARD 17)

find_package(llama CONFIG REQUIRED)

add_executable(MyLlamaApp main.cpp)
target_link_libraries(MyLlamaApp PRIVATE llama)

and my vcpkg.json file is:

{
  "name": "myllamaapp",
  "version": "0.1.0",
  "dependencies": [
    "llama-cpp"
  ]
 
}

when I try to buildproject using VS 2022 R 17, I am getting this log:

Detecting compiler hash for triplet x64-windows...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe
Detecting compiler hash for triplet x64-windows-static...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe
The following packages will be built and installed:
  * ggml:x64-windows-static@2025-05-13
    llama-cpp:x64-windows-static@4743#1
  * vcpkg-cmake:x64-windows@2024-04-23
  * vcpkg-cmake-config:x64-windows@2024-05-23
Additional packages (*) will be modified to complete this operation.
Restored 0 package(s) from C:\Users\M\AppData\Local\vcpkg\archives in 172 us. Use --debug to see more details.
Installing 1/4 vcpkg-cmake-config:x64-windows@2024-05-23...
Building vcpkg-cmake-config:x64-windows@2024-05-23...
-- Installing: D:/local/vcpkg/packages/vcpkg-cmake-config_x64-windows/share/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake
-- Installing: D:/local/vcpkg/packages/vcpkg-cmake-config_x64-windows/share/vcpkg-cmake-config/vcpkg-port-config.cmake
-- Installing: D:/local/vcpkg/packages/vcpkg-cmake-config_x64-windows/share/vcpkg-cmake-config/copyright
-- Skipping post-build validation due to VCPKG_POLICY_EMPTY_PACKAGE
Starting submission of vcpkg-cmake-config:x64-windows@2024-05-23 to 1 binary cache(s) in the background
Elapsed time to handle vcpkg-cmake-config:x64-windows: 57.6 ms
vcpkg-cmake-config:x64-windows package ABI: a6bbbf37c4a838266139abf2b8c3d1e24aeddbf61eecad99c783a970cf807611
Installing 2/4 vcpkg-cmake:x64-windows@2024-04-23...
Building vcpkg-cmake:x64-windows@2024-04-23...
-- Installing: D:/local/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_configure.cmake
-- Installing: D:/local/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake
-- Installing: D:/local/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake
-- Installing: D:/local/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg-port-config.cmake
-- Installing: D:/local/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/copyright
-- Performing post-build validation
Starting submission of vcpkg-cmake:x64-windows@2024-04-23 to 1 binary cache(s) in the background
Elapsed time to handle vcpkg-cmake:x64-windows: 72.6 ms
vcpkg-cmake:x64-windows package ABI: 377937e02d231e8e62f093ba0edd7848d535674283453168a97cf3a2c90b6158
Completed submission of vcpkg-cmake-config:x64-windows@2024-05-23 to 1 binary cache(s) in 44 ms
Installing 3/4 ggml:x64-windows-static@2025-05-13...
Building ggml:x64-windows-static@2025-05-13...
-- Using cached ggml-org-ggml-38648430fce1422694f2f349a5fe60d5969d6f49.tar.gz
-- Cleaning sources at D:/local/vcpkg/buildtrees/ggml/src/d5969d6f49-e3532476b4.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source D:/local/vcpkg/downloads/ggml-org-ggml-38648430fce1422694f2f349a5fe60d5969d6f49.tar.gz
-- Applying patch cmake-config.diff
-- Applying patch relax-link-options.diff
-- Applying patch vulkan-shaders-gen.diff
-- Using source at D:/local/vcpkg/buildtrees/ggml/src/d5969d6f49-e3532476b4.clean
-- Found external ninja('1.12.1').
-- Configuring x64-windows-static
-- Building x64-windows-static-dbg
-- Building x64-windows-static-rel
-- Fixing pkgconfig file: D:/local/vcpkg/packages/ggml_x64-windows-static/lib/pkgconfig/ggml.pc
-- Using cached msys2-mingw-w64-x86_64-pkgconf-1~2.4.3-1-any.pkg.tar.zst
-- Using cached msys2-msys2-runtime-3.6.2-2-x86_64.pkg.tar.zst
-- Using msys root at D:/local/vcpkg/downloads/tools/msys2/9272adbcaf19caef
-- Fixing pkgconfig file: D:/local/vcpkg/packages/ggml_x64-windows-static/debug/lib/pkgconfig/ggml.pc
-- Installing: D:/local/vcpkg/packages/ggml_x64-windows-static/share/ggml/copyright
-- Performing post-build validation
Starting submission of ggml:x64-windows-static@2025-05-13 to 1 binary cache(s) in the background
Elapsed time to handle ggml:x64-windows-static: 16 s
ggml:x64-windows-static package ABI: 8c2553ec8b5d858aa0ab9046d2bfd3571c5f644a9dfd505fced3a9c4e45b3e18
Completed submission of vcpkg-cmake:x64-windows@2024-04-23 to 1 binary cache(s) in 34.8 ms
Installing 4/4 llama-cpp:x64-windows-static@4743#1...
Building llama-cpp:x64-windows-static@4743#1...
-- Using cached ggml-org-llama.cpp-b4743.tar.gz
-- Cleaning sources at D:/local/vcpkg/buildtrees/llama-cpp/src/b4743-1f22f4caae.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source D:/local/vcpkg/downloads/ggml-org-llama.cpp-b4743.tar.gz
-- Applying patch 0001-external-ggml.patch
-- Using source at D:/local/vcpkg/buildtrees/llama-cpp/src/b4743-1f22f4caae.clean
-- Found external ninja('1.12.1').
-- Configuring x64-windows-static
-- Building x64-windows-static-dbg
-- Building x64-windows-static-rel
-- Fixing pkgconfig file: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/lib/pkgconfig/llama.pc
-- Using cached msys2-mingw-w64-x86_64-pkgconf-1~2.4.3-1-any.pkg.tar.zst
-- Using cached msys2-msys2-runtime-3.6.2-2-x86_64.pkg.tar.zst
-- Using msys root at D:/local/vcpkg/downloads/tools/msys2/9272adbcaf19caef
-- Fixing pkgconfig file: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/debug/lib/pkgconfig/llama.pc
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/examples
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/examples/reader.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/examples/writer.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/constants.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/gguf.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/gguf_reader.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/gguf_writer.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/lazy.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/metadata.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/py.typed
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/quants.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/scripts
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/scripts/gguf_convert_endian.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/scripts/gguf_dump.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/scripts/gguf_hash.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/scripts/gguf_new_metadata.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/scripts/gguf_set_metadata.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/scripts/__init__.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/tensor_mapping.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/utility.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/vocab.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/gguf/__init__.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/LICENSE
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/pyproject.toml
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/README.md
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/tests
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/tests/test_metadata.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/tests/test_quants.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/tools/llama-cpp/gguf-py/tests/__init__.py
-- Installing: D:/local/vcpkg/packages/llama-cpp_x64-windows-static/share/llama-cpp/copyright
-- Performing post-build validation
Starting submission of llama-cpp:x64-windows-static@4743#1 to 1 binary cache(s) in the background
Elapsed time to handle llama-cpp:x64-windows-static: 57 s
llama-cpp:x64-windows-static package ABI: 6e0c34c0030104853ed84b67e2b101e22b3a92fe52d32c35836dd50de0de1ca8
Installed contents are licensed to you by owners. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Packages installed in this vcpkg installation declare the following licenses:
MIT
llama-cpp provides CMake targets:

  # this is heuristically generated, and may not be correct
  find_package(llama CONFIG REQUIRED)
  target_link_libraries(main PRIVATE llama)

llama-cpp provides pkg-config modules:

  # Port of Facebook's LLaMA model in C/C++
  llama

Completed submission of ggml:x64-windows-static@2025-05-13 to 1 binary cache(s) in 1.1 s
Waiting for 1 remaining binary cache submissions...
Completed submission of llama-cpp:x64-windows-static@4743#1 to 1 binary cache(s) in 5.8 s (1/1)
All requested installations completed successfully in: 1.2 min

but then I am getting this error:

-- Running vcpkg install - done
-- The C compiler identification is MSVC 19.44.35209.0
-- The CXX compiler identification is MSVC 19.44.35209.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.44.35207/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at build/vcpkg_installed/x64-windows-static/share/llama/llama-config.cmake:16 (message):
  File or directory
  D:/CPP/TestApp_llama.cpp/build/vcpkg_installed/x64-windows-static/bin
  referenced by variable LLAMA_BIN_DIR does not exist !
Call Stack (most recent call first):
  build/vcpkg_installed/x64-windows-static/share/llama/llama-config.cmake:34 (set_and_check)
  D:/local/vcpkg/scripts/buildsystems/vcpkg.cmake:893 (_find_package)
  CMakeLists.txt:20 (find_package)


-- Configuring incomplete, errors occurred!

 Build complete.

checking for bin directory, it is not created there.

What is the problem and how I can fix it?

1
  • 3
    I think you should rename your question to something like "I cannot deploy my binary using vcpkg". And this error message D:/CPP/TestApp_llama.cpp/build/vcpkg_installed/x64-windows-static/bin referenced by variable LLAMA_BIN_DIR does not exist ! seems like a very clear place to start Commented Jun 21 at 4:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.