From 206459a80477f00799b383d4c7e81d207c95d00b Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 26 Mar 2025 16:21:07 +0100 Subject: [PATCH] bindings-go : update Makefile to use cmake (#2952) This commit updates the Makefile to use cmake instead of make to build whisper.cpp. The motivation for this change is that currently the make recipe test will fail with the following error: ```console $ make test Mkdir build Mkdir models Build whisper make[1]: Entering directory '/home/danbev/work/ai/whisper-work' make[1]: *** No rule to make target 'libwhisper.a'. Stop. make[1]: Leaving directory '/home/danbev/work/ai/whisper-work' make: *** [Makefile:33: whisper] Error 2 ``` --- bindings/go/Makefile | 10 ++++++---- bindings/go/whisper.go | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bindings/go/Makefile b/bindings/go/Makefile index ca39de20..edcc0166 100644 --- a/bindings/go/Makefile +++ b/bindings/go/Makefile @@ -11,11 +11,11 @@ UNAME_M := $(shell uname -m) endif GGML_METAL_PATH_RESOURCES := $(abspath ../..) -BUILD_DIR := build +BUILD_DIR := build_go MODELS_DIR := models EXAMPLES_DIR := $(wildcard examples/*) INCLUDE_PATH := $(abspath ../../include):$(abspath ../../ggml/include) -LIBRARY_PATH := $(abspath ../..) +LIBRARY_PATH := $(abspath ../../${BUILD_DIR}/src:$(abspath ../../${BUILD_DIR}/ggml/src)) ifeq ($(GGML_CUDA),1) LIBRARY_PATH := $(LIBRARY_PATH):$(CUDA_PATH)/targets/$(UNAME_M)-linux/lib/ @@ -29,8 +29,10 @@ endif all: clean whisper examples whisper: mkdir - @echo Build whisper - @${MAKE} -C ../.. libwhisper.a + cmake -S ../.. -B ../../${BUILD_DIR} \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF + cmake --build ../../${BUILD_DIR} --target whisper test: model-small whisper modtidy ifeq ($(UNAME_S),Darwin) diff --git a/bindings/go/whisper.go b/bindings/go/whisper.go index 39ec43b4..525b72d2 100644 --- a/bindings/go/whisper.go +++ b/bindings/go/whisper.go @@ -9,7 +9,7 @@ import ( // CGO /* -#cgo LDFLAGS: -lwhisper -lm -lstdc++ -fopenmp +#cgo LDFLAGS: -lwhisper -lggml -lggml-base -lggml-cpu -lm -lstdc++ -fopenmp #cgo darwin LDFLAGS: -framework Accelerate -framework Metal -framework Foundation -framework CoreGraphics #include #include