mattn/go-sqlite3

ld: warning: object file (...) was built for newer macOS version (12.0) than being linked (11.3)

Plorenzo opened this issue · 2 comments

I'm getting the following errors when building my go program.

# command-line-arguments
ld: warning: object file (/var/folders/yy/16g_7s717l358cwmrh87jc4w0000gn/T/go-link-1414785648/000012.o) was built for newer macOS version (12.0) than being linked (11.3)
ld: warning: object file (/var/folders/yy/16g_7s717l358cwmrh87jc4w0000gn/T/go-link-1414785648/000013.o) was built for newer macOS version (12.0) than being linked (11.3)
ld: warning: object file (/var/folders/yy/16g_7s717l358cwmrh87jc4w0000gn/T/go-link-1414785648/000014.o) was built for newer macOS version (12.0) than being linked (11.3)
ld: warning: object file (/var/folders/yy/16g_7s717l358cwmrh87jc4w0000gn/T/go-link-1414785648/000015.o) was built for newer macOS version (12.0) than being linked (11.3)
ld: warning: object file (/var/folders/yy/16g_7s717l358cwmrh87jc4w0000gn/T/go-link-1414785648/000016.o) was built for newer macOS version (12.0) than being linked (11.3)
ld: warning: object file (/var/folders/yy/16g_7s717l358cwmrh87jc4w0000gn/T/go-link-1414785648/000017.o) was built for newer macOS version (12.0) than being linked (11.3)
ld: warning: object file (/var/folders/yy/16g_7s717l358cwmrh87jc4w0000gn/T/go-link-1414785648/000018.o) was built for newer macOS version (12.0) than being linked (11.3)
ld: warning: object file (/var/folders/yy/16g_7s717l358cwmrh87jc4w0000gn/T/go-link-1414785648/000019.o) was built for newer macOS version (12.0) than being linked (11.3)
ld: warning: object file (/var/folders/yy/16g_7s717l358cwmrh87jc4w0000gn/T/go-link-1414785648/000020.o) was built for newer macOS version (12.0) than being linked (11.3)

macOS version

$ sw_vers
ProductName:	macOS
ProductVersion:	12.5
BuildVersion:	21G5027d
Go env
$ go env                                                                                                                                                                                                                                                                 
GO111MODULE=""
GOARCH="amd64"
GOBIN="/Users/plorenzo/dev/gorkspace/bin"
GOCACHE="/Users/plorenzo/Library/Caches/go-build"
GOENV="/Users/plorenzo/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/plorenzo/dev/gorkspace/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/plorenzo/dev/gorkspace"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.18.2/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.18.2/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/plorenzo/dev/gorkspace/scr/gitlab.com/plorenzo/test/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/yy/16g_7s717l358cwmrh87jc4w0000gn/T/go-build3374803040=/tmp/go-build -gno-record-gcc-switches -fno-common"

Minimun reproducible example

package main

import (
	"database/sql"

	_ "github.com/mattn/go-sqlite3"
)

func main() {
	sql.Open("sqlite3", "db")
}

It looks like you installed Go via Homebrew. As per this, you may need to update CommandLineTools (i.e., XCode).

Thank you for the pointer. Indeed reinstalling command line tools did the trick.

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install