-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
Minimal sqlite.go
package main
import (
"database/sql"
"fmt"
_ "github.com/mattn/go-sqlite3"
)
func main() {
fmt.Println("Started")
db, err := sql.Open("sqlite3", ":memory:")
if err != nil {
fmt.Printf("Error: %v\n", err)
}
fmt.Println("Database opened successfully")
err = db.Ping()
if err != nil {
fmt.Printf("Error: %v\n", err)
}
fmt.Println("Database ping successful")
if _, err := db.Exec(`CREATE TABLE test (
id INTEGER PRIMARY KEY
);
`); err != nil {
fmt.Printf("Error: %v\n", err)
}
fmt.Println("Table created")
fmt.Println("Done")
}
BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "sqlite_lib",
srcs = ["sqlite.go"],
importpath = "gmbuell/project/sqlite",
visibility = ["//visibility:private"],
deps = ["@com_github_mattn_go_sqlite3//:go-sqlite3"],
)
go_binary(
name = "sqlite",
embed = [":sqlite_lib"],
visibility = ["//visibility:public"],
)
Testing on linux:
bazel run :sqlite
gives the expected output:
Started
Database opened successfully
Database ping successful
Table created
Done
Building for windows:
BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 bazel build :sqlite --platforms=@zig_sdk//platform:windows_amd64 --extra_toolchains @zig_sdk//toolchain:windows_amd64
If I run the exe with wine, I get the expected output:
Started
Database opened successfully
Database ping successful
Table created
Done
But actually running the exe on WIndows gives
PS Z:\> .\sqlite.exe
Started
Database opened successfully
With the program then exiting silently (presumably crashing somewhere?)
Any ideas? I would assume cross compiling sqlite3 would be a fairly common use case for this toolchain.
Metadata
Metadata
Assignees
Labels
No labels