The server this is running against is running Red Hat 5.3, which is my company's standard Linux install. I tried creating a go installation on this server, and compiling gosqlite fails:
CGOPKGPATH= cgo -- sqlite.go
touch _obj/_cgo_run
6g -o _go_.6 _obj/sqlite.cgo1.go _obj/_cgo_gotypes.go
6c -FVw -I/home/n1rmasci/go/pkg/linux_amd64 -I . -o "_cgo_defun.6" _obj/_cgo_defun.c
gcc -m64 -I . -g -fPIC -O2 -o _cgo_main.o -c _obj/_cgo_main.c
gcc -m64 -I . -g -fPIC -O2 -o sqlite.cgo2.o -c _obj/sqlite.cgo2.c
sqlite.go: In function '_cgo_949207f1712e_Cfunc_sqlite3_prepare_v2':
sqlite.go:309: warning: passing argument 5 of 'sqlite3_prepare_v2' from incompatible pointer type
gcc -m64 -I . -g -fPIC -O2 -o _cgo_export.o -c _obj/_cgo_export.c
gcc -m64 -g -fPIC -O2 -o _cgo1_.o _cgo_main.o sqlite.cgo2.o _cgo_export.o -L/usr/local/lib/oeis -lsqlite3
sqlite.cgo2.o: In function `_cgo_949207f1712e_Cfunc_sqlite3_threadsafe':
/home/n1rmasci/go/src/pkg/sqlite/sqlite.go:319: undefined reference to `sqlite3_threadsafe'
sqlite.cgo2.o: In function `_cgo_949207f1712e_Cfunc_sqlite3_prepare_v2':
/home/n1rmasci/go/src/pkg/sqlite/sqlite.go:309: undefined reference to `sqlite3_prepare_v2'
sqlite.cgo2.o: In function `_cgo_949207f1712e_Cfunc_sqlite3_open_v2':
/home/n1rmasci/go/src/pkg/sqlite/sqlite.go:273: undefined reference to `sqlite3_open_v2'
sqlite.cgo2.o: In function `_cgo_949207f1712e_Cfunc_sqlite3_backup_pagecount':
/home/n1rmasci/go/src/pkg/sqlite/sqlite.go:246: undefined reference to `sqlite3_backup_pagecount'
sqlite.cgo2.o: In function `_cgo_949207f1712e_Cfunc_sqlite3_backup_remaining':
/home/n1rmasci/go/src/pkg/sqlite/sqlite.go:163: undefined reference to `sqlite3_backup_remaining'
sqlite.cgo2.o: In function `_cgo_949207f1712e_Cfunc_sqlite3_backup_step':
/home/n1rmasci/go/src/pkg/sqlite/sqlite.go:117: undefined reference to `sqlite3_backup_step'
sqlite.cgo2.o: In function `_cgo_949207f1712e_Cfunc_sqlite3_backup_finish':
/home/n1rmasci/go/src/pkg/sqlite/sqlite.go:104: undefined reference to `sqlite3_backup_finish'
sqlite.cgo2.o: In function `_cgo_949207f1712e_Cfunc_sqlite3_backup_init':
/home/n1rmasci/go/src/pkg/sqlite/sqlite.go:93: undefined reference to `sqlite3_backup_init'
collect2: ld returned 1 exit status
make: *** [_cgo1_.o] Error 1
[user@myserver sqlite]$ cat Makefile
# Copyright 2010 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
include $(GOROOT)/src/Make.inc
TARG=sqlite
CGOFILES=\
sqlite.go
ifeq ($(GOOS),darwin)
CGO_LDFLAGS=/usr/lib/libsqlite3.0.dylib
else
CGO_LDFLAGS=-L/usr/local/lib/oeis -lsqlite3
endif
include $(GOROOT)/src/Make.pkg
[user@myserver sqlite]$
The only thing is I changed from the original Makefile is the TARG.
There are a lot of applications that depend upon sqlite on the server I have to run my report on so I am hesitant to upgrade the version of sqlite. What I did to fix it was to compile the latest version of sqlite. I then had an administrator put the new compiled sqlite in /usr/local/sqlite. I then had the administrator create an /etc/ld.so.conf.d/mysql_report.conf that contained one line: /usr/local/sqlite/lib, and then he ran ldconfig. Now the system looks in /usr/local/sqlite/lib when my application is run.
This is very ugly workaround, so I am hoping someone will have a better solution.