[GH-ISSUE #5054] Windows - go generate failing on build_cpu #65229

Closed
opened 2026-05-03 20:04:37 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @JerrettDavis on GitHub (Jun 15, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/5054

Originally assigned to: @dhiltgen on GitHub.

What is the issue?

I've been trying to get a Windows dev environment up and running following the development guide. I've attempted installing both MinGW-w64 and MSYS2, along with the latest Visual Studio build tools, but the existing Windows build script does not seem to work out-of-the-box. I've tried swapping paths, moving which cmake is actually getting used, setting the default generator through environment variables, and quite a bit more.

When running go generate ./... some variation of the following error is shown:

Building LCD CPU
generating config with: cmake -S ../llama.cpp -B ../build/windows/amd64/cpu -DCMAKE_POSITION_INDEPENDENT_CODE=on -A x64 -DLLAMA_AVX=off -DLLAMA_AVX2=off -DLLAMA_AVX512=off -DLLAMA_FMA=off -DLLAMA_F16C=off -DBUILD_SHARED_LIBS=on -DLLAMA_NATIVE=off -DLLAMA_SERVER_VERBOSE=off -DCMAKE_BUILD_TYPE=Release
cmake version 3.28.3-msvc11

CMake suite maintained and supported by Kitware (kitware.com/cmake).
CMake Error at CMakeLists.txt:2 (project):
  Generator

    Ninja

  does not support platform specification, but platform

    x64

  was specified.


CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
llm\generate\generate_windows.go:3: running "powershell": exit status 1

The crux of the issue seems to be the default generator (ninja). It does not accept the -A argument that the Visual Studio generators do.

OS

Windows

GPU

Nvidia

CPU

Intel

Ollama version

0.1.44

Originally created by @JerrettDavis on GitHub (Jun 15, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/5054 Originally assigned to: @dhiltgen on GitHub. ### What is the issue? I've been trying to get a Windows dev environment up and running following the [development](https://github.com/ollama/ollama/blob/main/docs/development.md) guide. I've attempted installing both MinGW-w64 and MSYS2, along with the latest Visual Studio build tools, but the existing Windows build script does not seem to work out-of-the-box. I've tried swapping paths, moving which cmake is actually getting used, setting the default generator through environment variables, and quite a bit more. When running `go generate ./...` some variation of the following error is shown: ``` Building LCD CPU generating config with: cmake -S ../llama.cpp -B ../build/windows/amd64/cpu -DCMAKE_POSITION_INDEPENDENT_CODE=on -A x64 -DLLAMA_AVX=off -DLLAMA_AVX2=off -DLLAMA_AVX512=off -DLLAMA_FMA=off -DLLAMA_F16C=off -DBUILD_SHARED_LIBS=on -DLLAMA_NATIVE=off -DLLAMA_SERVER_VERBOSE=off -DCMAKE_BUILD_TYPE=Release cmake version 3.28.3-msvc11 CMake suite maintained and supported by Kitware (kitware.com/cmake). CMake Error at CMakeLists.txt:2 (project): Generator Ninja does not support platform specification, but platform x64 was specified. CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred! llm\generate\generate_windows.go:3: running "powershell": exit status 1 ``` The crux of the issue seems to be the default generator (ninja). It does not accept the `-A` argument that the Visual Studio generators do. ### OS Windows ### GPU Nvidia ### CPU Intel ### Ollama version 0.1.44
GiteaMirror added the buildbugneeds more infowindows labels 2026-05-03 20:04:38 -05:00
Author
Owner

@JerrettDavis commented on GitHub (Jun 15, 2024):

I managed to fix the issue on my machine by updating the gen_windows.ps1 script a bit. I updated the script to check cmake for all the installed generators when compiling for CPU. It then selects the latest version of visual studio (if found), and passes it as the generator to the cmake command for those operations.

function select_latest_vs_generator {
    # Check for available CMake generators
    $capabilities = cmake -E capabilities | ConvertFrom-Json
    $generators = $capabilities.generators

    # Find the latest version of Visual Studio generator
    $latestVSGenerator = $null
    $latestMajor = 0
    $latestMinor = 0
    foreach ($generator in $generators) {
        if ($generator.name -match "Visual Studio (\d+) (\d+)") {
            $major = [int]$matches[1]
            $minor = [int]$matches[2]
            if ($major -gt $latestMajor -or ($major -eq $latestMajor -and $minor -gt $latestMinor)) {
                $latestMajor = $major
                $latestMinor = $minor
                $latestVSGenerator = "$major $minor"
            }
        }
    }

    if ($null -ne $latestVSGenerator) {
        return "Visual Studio $latestVSGenerator"
    } else {
        throw "No Visual Studio CMake generators found."
    }
}

function build_cpu($gen_arch) {
    if ((-not "${env:OLLAMA_SKIP_CPU_GENERATE}" ) -and ((-not "${env:OLLAMA_CPU_TARGET}") -or ("${env:OLLAMA_CPU_TARGET}" -eq "cpu"))) {
        $generator = select_latest_vs_generator

        # Remaining llama.cpp builds use MSVC 
        init_vars
        $uniqueBuildDir = "../build/windows/${script:ARCH}/cpu_$($generator.Replace(' ', '_'))"
        $script:cmakeDefs = $script:commonCpuDefs + @("-A", $gen_arch, "-DLLAMA_AVX=off", "-DLLAMA_AVX2=off", "-DLLAMA_AVX512=off", "-DLLAMA_FMA=off", "-DLLAMA_F16C=off") + $script:cmakeDefs + @("-G", $generator)
        $script:buildDir=$uniqueBuildDir
        $script:distDir="$script:DIST_BASE\cpu"
        write-host "Building LCD CPU"
        build
        sign
        install
    } else {
        write-host "Skipping CPU generation step as requested"
    }
}

function build_cpu_avx() {
    if ((-not "${env:OLLAMA_SKIP_CPU_GENERATE}" ) -and ((-not "${env:OLLAMA_CPU_TARGET}") -or ("${env:OLLAMA_CPU_TARGET}" -eq "cpu_avx"))) {
        $generator = select_latest_vs_generator

        init_vars
        $uniqueBuildDir = "../build/windows/${script:ARCH}/cpu_avx_$($generator.Replace(' ', '_'))"
        $script:cmakeDefs = $script:commonCpuDefs + @("-A", "x64", "-DLLAMA_AVX=on", "-DLLAMA_AVX2=off", "-DLLAMA_AVX512=off", "-DLLAMA_FMA=off", "-DLLAMA_F16C=off") + $script:cmakeDefs + @("-G", $generator)
        $script:buildDir=$uniqueBuildDir
        $script:distDir="$script:DIST_BASE\cpu_avx"
        write-host "Building AVX CPU"
        build
        sign
        install
    } else {
        write-host "Skipping CPU AVX generation step as requested"
    }
}

function build_cpu_avx2() {
    if ((-not "${env:OLLAMA_SKIP_CPU_GENERATE}" ) -and ((-not "${env:OLLAMA_CPU_TARGET}") -or ("${env:OLLAMA_CPU_TARGET}" -eq "cpu_avx2"))) {
        $generator = select_latest_vs_generator

        init_vars
        $uniqueBuildDir = "../build/windows/${script:ARCH}/cpu_avx2_$($generator.Replace(' ', '_'))"
        $script:cmakeDefs = $script:commonCpuDefs + @("-A", "x64", "-DLLAMA_AVX=on", "-DLLAMA_AVX2=on", "-DLLAMA_AVX512=off", "-DLLAMA_FMA=on", "-DLLAMA_F16C=on") + $script:cmakeDefs + @("-G", $generator)
        $script:buildDir=$uniqueBuildDir
        $script:distDir="$script:DIST_BASE\cpu_avx2"
        write-host "Building AVX2 CPU"
        build
        sign
        install
    } else {
        write-host "Skipping CPU AVX2 generation step as requested"
    }
}
<!-- gh-comment-id:2169046673 --> @JerrettDavis commented on GitHub (Jun 15, 2024): I managed to fix the issue on my machine by updating the `gen_windows.ps1` script a bit. I updated the script to check cmake for all the installed generators when compiling for CPU. It then selects the latest version of visual studio (if found), and passes it as the generator to the cmake command for those operations. ```ps function select_latest_vs_generator { # Check for available CMake generators $capabilities = cmake -E capabilities | ConvertFrom-Json $generators = $capabilities.generators # Find the latest version of Visual Studio generator $latestVSGenerator = $null $latestMajor = 0 $latestMinor = 0 foreach ($generator in $generators) { if ($generator.name -match "Visual Studio (\d+) (\d+)") { $major = [int]$matches[1] $minor = [int]$matches[2] if ($major -gt $latestMajor -or ($major -eq $latestMajor -and $minor -gt $latestMinor)) { $latestMajor = $major $latestMinor = $minor $latestVSGenerator = "$major $minor" } } } if ($null -ne $latestVSGenerator) { return "Visual Studio $latestVSGenerator" } else { throw "No Visual Studio CMake generators found." } } function build_cpu($gen_arch) { if ((-not "${env:OLLAMA_SKIP_CPU_GENERATE}" ) -and ((-not "${env:OLLAMA_CPU_TARGET}") -or ("${env:OLLAMA_CPU_TARGET}" -eq "cpu"))) { $generator = select_latest_vs_generator # Remaining llama.cpp builds use MSVC init_vars $uniqueBuildDir = "../build/windows/${script:ARCH}/cpu_$($generator.Replace(' ', '_'))" $script:cmakeDefs = $script:commonCpuDefs + @("-A", $gen_arch, "-DLLAMA_AVX=off", "-DLLAMA_AVX2=off", "-DLLAMA_AVX512=off", "-DLLAMA_FMA=off", "-DLLAMA_F16C=off") + $script:cmakeDefs + @("-G", $generator) $script:buildDir=$uniqueBuildDir $script:distDir="$script:DIST_BASE\cpu" write-host "Building LCD CPU" build sign install } else { write-host "Skipping CPU generation step as requested" } } function build_cpu_avx() { if ((-not "${env:OLLAMA_SKIP_CPU_GENERATE}" ) -and ((-not "${env:OLLAMA_CPU_TARGET}") -or ("${env:OLLAMA_CPU_TARGET}" -eq "cpu_avx"))) { $generator = select_latest_vs_generator init_vars $uniqueBuildDir = "../build/windows/${script:ARCH}/cpu_avx_$($generator.Replace(' ', '_'))" $script:cmakeDefs = $script:commonCpuDefs + @("-A", "x64", "-DLLAMA_AVX=on", "-DLLAMA_AVX2=off", "-DLLAMA_AVX512=off", "-DLLAMA_FMA=off", "-DLLAMA_F16C=off") + $script:cmakeDefs + @("-G", $generator) $script:buildDir=$uniqueBuildDir $script:distDir="$script:DIST_BASE\cpu_avx" write-host "Building AVX CPU" build sign install } else { write-host "Skipping CPU AVX generation step as requested" } } function build_cpu_avx2() { if ((-not "${env:OLLAMA_SKIP_CPU_GENERATE}" ) -and ((-not "${env:OLLAMA_CPU_TARGET}") -or ("${env:OLLAMA_CPU_TARGET}" -eq "cpu_avx2"))) { $generator = select_latest_vs_generator init_vars $uniqueBuildDir = "../build/windows/${script:ARCH}/cpu_avx2_$($generator.Replace(' ', '_'))" $script:cmakeDefs = $script:commonCpuDefs + @("-A", "x64", "-DLLAMA_AVX=on", "-DLLAMA_AVX2=on", "-DLLAMA_AVX512=off", "-DLLAMA_FMA=on", "-DLLAMA_F16C=on") + $script:cmakeDefs + @("-G", $generator) $script:buildDir=$uniqueBuildDir $script:distDir="$script:DIST_BASE\cpu_avx2" write-host "Building AVX2 CPU" build sign install } else { write-host "Skipping CPU AVX2 generation step as requested" } } ```
Author
Owner

@rafaelgdn commented on GitHub (Aug 31, 2024):

For some reasons, this worked for me as with your code it was outputting 2022 and not 2019:

# Find the latest version of Visual Studio generator $latestVSGenerator = $null $latestMajor = 16 $latestMinor = 2019 $latestVSGenerator = "$latestMajor $latestMinor"

Actually since my goal is to support gfx1031 so rocm I set $latestVSGenerator = Ninja if ($null -ne $latestVSGenerator) { return "$latestVSGenerator" }

Running the final exe give me : c1 : fatal error C1083: Cannot open source file: 'hip': No such file or directory [C:\Users\User\Desktop\AI\ollama\llm\build\windows\amd64\rocm_v5.7\ggml\ src\ggml.vcxproj]

My goal is to run on windows 10 ollama with my AMD Radeon RX 6700 XT which doesn't seems to be compatible with HIP SDK.

Anyone?

same here. found a way to fix?

<!-- gh-comment-id:2322969855 --> @rafaelgdn commented on GitHub (Aug 31, 2024): > For some reasons, this worked for me as with your code it was outputting 2022 and not 2019: > > `# Find the latest version of Visual Studio generator $latestVSGenerator = $null $latestMajor = 16 $latestMinor = 2019 $latestVSGenerator = "$latestMajor $latestMinor"` > > Actually since my goal is to support gfx1031 so rocm I set `$latestVSGenerator = Ninja if ($null -ne $latestVSGenerator) { return "$latestVSGenerator" }` > > Running the final exe give me : `c1 : fatal error C1083: Cannot open source file: 'hip': No such file or directory [C:\Users\User\Desktop\AI\ollama\llm\build\windows\amd64\rocm_v5.7\ggml\ src\ggml.vcxproj]` > > My goal is to run on windows 10 ollama with my AMD Radeon RX 6700 XT which doesn't seems to be compatible with HIP SDK. > > Anyone? same here. found a way to fix?
Author
Owner

@dhiltgen commented on GitHub (Oct 23, 2024):

We've adjusted the build process for the new Go server to simplify the dependencies on Windows. Please give it a shot and let us know if you have any problems getting it to compile.

https://github.com/ollama/ollama/blob/main/docs/development.md#transition-to-go-runner

<!-- gh-comment-id:2433524118 --> @dhiltgen commented on GitHub (Oct 23, 2024): We've adjusted the build process for the new Go server to simplify the dependencies on Windows. Please give it a shot and let us know if you have any problems getting it to compile. https://github.com/ollama/ollama/blob/main/docs/development.md#transition-to-go-runner
Author
Owner

@dhiltgen commented on GitHub (Nov 4, 2024):

If you have any trouble getting the new build working let us know and I'll reopen.

<!-- gh-comment-id:2455507466 --> @dhiltgen commented on GitHub (Nov 4, 2024): If you have any trouble getting the new build working let us know and I'll reopen.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#65229