asg017 / sqlite-vec-go-bindings

sqlite-vec WASM bindings for ncruces/go-sqlite3, published as a separate repo
12 stars 2 forks source link

sqlite3ext.h: No such file or directory #1

Open armyja opened 2 months ago

armyja commented 2 months ago
./sqlite-vec.h:4:10: fatal error: sqlite3ext.h: No such file or directory
    4 | #include "sqlite3ext.h"
      |          ^~~~~~~~~~~~~~
compilation terminated.

To solve the compilation error, I have to add environment variable:

 $env:CGO_CFLAGS="-I C:\Users\xxxxxxxx\go\pkg\mod\github.com\mattn\go-sqlite3@v1.14.22"

Are there any simpler alternatives?

wjkoh commented 1 month ago

+1

asg017 commented 1 month ago

@wjkoh can you try with the just released v0.1.3-alpha.1? I believe I fixed the sqlite3ext.h with that one, and the "undefined symbol sqrtf" error should also be fixed.

wjkoh commented 1 month ago

@asg017 It works! After upgrading to v0.1.3-alpha.1, I was able to build a binary with the system-wide libsqlite3 without a problem. See the Dockerfile at the end.

One caveat is the golang:1.23 image uses Debian Bookworm as the base image and it has SQLite 3.40.1-2, which doesn't have JSONB support. That's the only drawback. Also, if you use a multi-stage build, don't forget to copy libsqlite3.so.0 from the builder image to the final image.

FROM golang:1.23 as builder

ENV CGO_ENABLED=1

RUN apt-get update \
 && DEBIAN_FRONTEND=noninteractive \
    apt-get install --no-install-recommends --assume-yes \
      libsqlite3-dev

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .
RUN go build -tags libsqlite3 -o server ./cmd/vino
markuswustenberg commented 1 month ago

@wjkoh you can get around this by installing libsqlite3-dev from trixie instead, which gives you SQLite 3.46.0 at the time of writing:

FROM golang
WORKDIR /src

RUN echo "deb http://deb.debian.org/debian trixie main" >>/etc/apt/sources.list
RUN set -x && apt-get update && \
  DEBIAN_FRONTEND=noninteractive apt-get install -y libsqlite3-dev/trixie

COPY go.mod go.sum ./
RUN go mod download

COPY . ./

ARG TARGETARCH
RUN GOOS=linux GOARCH=${TARGETARCH} CGO_ENABLED=1 go build -tags fts5,libsqlite3 -buildvcs=false -ldflags="-s -w" -o /bin/api ./cmd/api