Closed fayfive closed 3 months ago
In makefile:143, move -lm to the end of the command
Hello,I don't want to compile the lib, I just want test, I enter the directory example/simple-go-cgo
and 'make' and show that
go build -o demo
# github.com/asg017/sqlite-vec/examples/go
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-3424282799/000002.o: in function `distance_cosine_float':
/home/alfred/go/pkg/mod/github.com/asg017/sqlite-vec-go-bindings@v0.1.1/cgo/sqlite-vec.c:464: undefined reference to `sqrt'
/usr/bin/ld: /home/alfred/go/pkg/mod/github.com/asg017/sqlite-vec-go-bindings@v0.1.1/cgo/sqlite-vec.c:464: undefined reference to `sqrt'
/usr/bin/ld: /tmp/go-link-3424282799/000002.o: in function `distance_cosine_int8':
/home/alfred/go/pkg/mod/github.com/asg017/sqlite-vec-go-bindings@v0.1.1/cgo/sqlite-vec.c:482: undefined reference to `sqrt'
/usr/bin/ld: /home/alfred/go/pkg/mod/github.com/asg017/sqlite-vec-go-bindings@v0.1.1/cgo/sqlite-vec.c:482: undefined reference to `sqrt'
/usr/bin/ld: /tmp/go-link-3424282799/000002.o: in function `vec_normalize':
/home/alfred/go/pkg/mod/github.com/asg017/sqlite-vec-go-bindings@v0.1.1/cgo/sqlite-vec.c:1747: undefined reference to `sqrtf'
/usr/bin/ld: /tmp/go-link-3424282799/000002.o: in function `l2_sqr_int8':
/home/alfred/go/pkg/mod/github.com/asg017/sqlite-vec-go-bindings@v0.1.1/cgo/sqlite-vec.c:374: undefined reference to `sqrtf'
/usr/bin/ld: /tmp/go-link-3424282799/000002.o: in function `l2_sqr_float':
/home/alfred/go/pkg/mod/github.com/asg017/sqlite-vec-go-bindings@v0.1.1/cgo/sqlite-vec.c:359: undefined reference to `sqrtf'
/usr/bin/ld: /tmp/go-link-3424282799/000002.o: in function `l2_sqr_int8':
/home/alfred/go/pkg/mod/github.com/asg017/sqlite-vec-go-bindings@v0.1.1/cgo/sqlite-vec.c:374: undefined reference to `sqrtf'
I upgrade the example/simple-go-cgo/go.mod
module github.com/asg017/sqlite-vec/examples/go
go 1.22.5
require github.com/mattn/go-sqlite3 v1.14.22
require github.com/asg017/sqlite-vec-go-bindings v0.1.1
And I found that go/pkg/mod/github.com/asg017/sqlite-vec-go-bindings@v0.1.1/cgo/lib.go
// #cgo CFLAGS: -DSQLITE_CORE
// #include "sqlite-vec.h"
It seems that there is no lib and the directory similarly like this
// #cgo LDFLAGS: -L/usr/lib/x86_64-linux-gnu
// #cgo LDFLAGS: -ldl -lm
Can you show me how to compile the sample? My system is ubuntu 22.04 go version is 1.22.6 I find the include file /usr/include/math.h the lib /usr/lib/x86_64-linux-gnu/libm.so Thanks!
@fayfive can you try again with the latest v0.1.2-alpha.7
verision? I added -lm
to cgo LDFLAGS for linux environments, hopefully that fixes it
Yes, it works well.
I compile
examples/simple-go-cgo/demo.go
with commandgo build
Here isgo env
My system is ubuntu 22.04
go version
is 1.22.6 I find the include file/usr/include/math.h
the lib/usr/lib/x86_64-linux-gnu/libm.so
Thanks!