mattn / go-sqlite3

sqlite3 driver for go using database/sql

Home Page:http://mattn.github.io/go-sqlite3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compiling on OSX fails part 2 looks like mattn/go-sqlite3#80

ms4720 opened this issue · comments

I am trying to get the simple.go example to run and it is not finding the symbols it needs, somewhat new at being a go dev and have not done this seriously in 15+ years so a bit rusty . thanks for the help. the original issue came up in a beego website I am trying to write

go version
go version go1.4.2 darwin/amd64

marcmac:simple ms4720$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.922/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.922/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)

marcmac:simple ms4720$ which clang
/usr/bin/clang
marcmac:simple ms4720$ clang -v
Apple clang version 3.1 (tags/Apple/clang-318.0.45) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

OSX version 10.7.5

marcmac:simple ms4720$ go build simple.go

command-line-arguments

github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol close
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol access
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol getcwd
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol stat$INODE64
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol fstat$INODE64
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol ftruncate
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol fcntl
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol read
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol pread
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol write
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol pwrite
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol fchmod
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol unlink
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol mkdir
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol rmdir
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol mmap
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol munmap
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for close (type 32 rtype 1)
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for access (type 32 rtype 1)
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for getcwd (type 32 rtype 1)
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for stat$INODE64 (type 32 rtype 1)
too many errors
marcmac:simple ms4720$ ls
simple.go

If go env helps, here it is:

marcmac:simple ms4720$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/ms4720/gocode"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fno-common"
CXX="g++"
CGO_ENABLED="1"

better build log info:

marcmac:simple ms4720$ go build -a -work -x simple.go
WORK=/var/folders/m6/z60mrgw56ybf0qvz2vgxckyr0000gn/T/go-build950612955
mkdir -p $WORK/github.com/mattn/go-sqlite3/_obj/
mkdir -p $WORK/github.com/mattn/
cd /Users/ms4720/gocode/src/github.com/mattn/go-sqlite3
CGO_LDFLAGS="-g" "-O2" /usr/local/go/pkg/tool/darwin_amd64/cgo -objdir $WORK/github.com/mattn/go-sqlite3/_obj/ -- -I $WORK/github.com/mattn/go-sqlite3/_obj/ -std=gnu99 -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -I. backup.go error.go sqlite3.go sqlite3_other.go
/usr/local/go/pkg/tool/darwin_amd64/6c -F -V -w -trimpath $WORK -I $WORK/github.com/mattn/go-sqlite3/_obj/ -I /usr/local/go/pkg/darwin_amd64 -o $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_defun.6 -D GOOS_darwin -D GOARCH_amd64 $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_defun.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fno-common -print-libgcc-file-name
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fno-common -I $WORK/github.com/mattn/go-sqlite3/_obj/ -g -O2 -std=gnu99 -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -I. -o $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_main.o -c $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_main.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fno-common -I $WORK/github.com/mattn/go-sqlite3/_obj/ -g -O2 -std=gnu99 -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -I. -o $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_export.o -c $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_export.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fno-common -I $WORK/github.com/mattn/go-sqlite3/_obj/ -g -O2 -std=gnu99 -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -I. -o $WORK/github.com/mattn/go-sqlite3/_obj/backup.cgo2.o -c $WORK/github.com/mattn/go-sqlite3/_obj/backup.cgo2.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fno-common -I $WORK/github.com/mattn/go-sqlite3/_obj/ -g -O2 -std=gnu99 -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -I. -o $WORK/github.com/mattn/go-sqlite3/_obj/error.cgo2.o -c $WORK/github.com/mattn/go-sqlite3/_obj/error.cgo2.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fno-common -I $WORK/github.com/mattn/go-sqlite3/_obj/ -g -O2 -std=gnu99 -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -I. -o $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3.cgo2.o -c $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3.cgo2.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fno-common -I $WORK/github.com/mattn/go-sqlite3/_obj/ -g -O2 -std=gnu99 -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -I. -o $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3_other.cgo2.o -c $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3_other.cgo2.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fno-common -I $WORK/github.com/mattn/go-sqlite3/_obj/ -g -O2 -std=gnu99 -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -I. -o $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3-binding.o -c ./sqlite3-binding.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fno-common -o $WORK/github.com/mattn/go-sqlite3/_obj/cgo.o $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_main.o $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_export.o $WORK/github.com/mattn/go-sqlite3/_obj/backup.cgo2.o $WORK/github.com/mattn/go-sqlite3/_obj/error.cgo2.o $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3.cgo2.o $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3_other.cgo2.o $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3-binding.o -g -O2
/usr/local/go/pkg/tool/darwin_amd64/cgo -objdir $WORK/github.com/mattn/go-sqlite3/_obj/ -dynimport $WORK/github.com/mattn/go-sqlite3/_obj/cgo.o -dynout $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_import.c
/usr/local/go/pkg/tool/darwin_amd64/6c -F -V -w -trimpath $WORK -I $WORK/github.com/mattn/go-sqlite3/_obj/ -I /usr/local/go/pkg/darwin_amd64 -o $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_import.6 -D GOOS_darwin -D GOARCH_amd64 $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_import.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fno-common -o $WORK/github.com/mattn/go-sqlite3/_obj/_all.o $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_export.o $WORK/github.com/mattn/go-sqlite3/_obj/backup.cgo2.o $WORK/github.com/mattn/go-sqlite3/_obj/error.cgo2.o $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3.cgo2.o $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3_other.cgo2.o $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3-binding.o -g -O2 -Wl,-r -nostdlib /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/x86_64/libgcc.a
/usr/local/go/pkg/tool/darwin_amd64/6g -o $WORK/github.com/mattn/go-sqlite3.a -trimpath $WORK -p github.com/mattn/go-sqlite3 -D _/Users/ms4720/gocode/src/github.com/mattn/go-sqlite3 -I $WORK -pack ./doc.go $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_gotypes.go $WORK/github.com/mattn/go-sqlite3/_obj/backup.cgo1.go $WORK/github.com/mattn/go-sqlite3/_obj/error.cgo1.go $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3.cgo1.go $WORK/github.com/mattn/go-sqlite3/_obj/sqlite3_other.cgo1.go
pack r $WORK/github.com/mattn/go-sqlite3.a $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_import.6 $WORK/github.com/mattn/go-sqlite3/_obj/_cgo_defun.6 $WORK/github.com/mattn/go-sqlite3/_obj/_all.o # internal
mkdir -p $WORK/command-line-arguments/_obj/
cd /Users/ms4720/gocode/src/github.com/mattn/go-sqlite3/_example/simple
/usr/local/go/pkg/tool/darwin_amd64/6g -o $WORK/command-line-arguments.a -trimpath $WORK -p command-line-arguments -complete -D _/Users/ms4720/gocode/src/github.com/mattn/go-sqlite3/_example/simple -I $WORK -I /Users/ms4720/gocode/pkg/darwin_amd64 -pack ./simple.go
cd .
/usr/local/go/pkg/tool/darwin_amd64/6l -o simple -L $WORK -L /Users/ms4720/gocode/pkg/darwin_amd64 -extld=gcc $WORK/command-line-arguments.a

command-line-arguments

github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol close
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol access
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol getcwd
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol stat$INODE64
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol fstat$INODE64
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol ftruncate
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol fcntl
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol read
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol pread
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol write
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol pwrite
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol fchmod
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol unlink
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol mkdir
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol rmdir
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol mmap
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol munmap
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for close (type 32 rtype 1)
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for access (type 32 rtype 1)
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for getcwd (type 32 rtype 1)
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for stat$INODE64 (type 32 rtype 1)
too many errors
marcmac:simple ms4720$

commented

Try with below?

$ export CC=clang

No joy and thanks for the help, env and go run output:

marcmac:simple ms4720$ env
TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/m6/z60mrgw56ybf0qvz2vgxckyr0000gn/T/
Apple_PubSub_Socket_Render=/tmp/launch-Mj9ll0/Render
TERM_PROGRAM_VERSION=303.2
OLDPWD=/Users/ms4720/gocode/src
TERM_SESSION_ID=69490B84-9A17-4A9A-8967-EC4C1CFB0289
USER=ms4720
COMMAND_MODE=unix2003
SSH_AUTH_SOCK=/tmp/launch-WFDjF0/Listeners
TERM_SESSION_CLASS_ID=3079A7FD-5BC0-43E3-8F5C-E0C7B895AD07
Apple_Ubiquity_Message=/tmp/launch-yksdh9/Apple_Ubiquity_Message
__CF_USER_TEXT_ENCODING=0x1F5:0:0
PATH=/Users/ms4720/local/bin:/Users/ms4720/gocode/bin:/Applications/Postgres.app/Contents/Versions/9.4/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/go/bin:/Users/ms4720/.gem/ruby/1.8/bin:/Users/ms4720/context/tex/texmf-osx-64/bin:/Applications/Postgres.app/Contents/Versions/9.4/bin
PWD=/Users/ms4720/gocode/src/github.com/mattn/go-sqlite3/_example/simple
DBUS_LAUNCHD_SESSION_BUS_SOCKET=/tmp/launch-kylCnF/unix_domain_listener
LANG=en_US.UTF-8
HOME=/Users/ms4720
SHLVL=1
LOGNAME=ms4720
GOPATH=/Users/ms4720/gocode
CC=clang
DISPLAY=/tmp/launch-nihRMq/org.x:0
SECURITYSESSIONID=186a9
OSFONTDIR=/usr/local/share/fonts;/Users/ms4720/.fonts
_=/usr/bin/env

marcmac:simple ms4720$ go run simple.go

command-line-arguments

github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol close
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol access
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol getcwd
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol stat$INODE64
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol fstat$INODE64
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol ftruncate
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol fcntl
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol read
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol pread
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol write
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol pwrite
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol fchmod
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol unlink
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol mkdir
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol rmdir
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol mmap
github.com/mattn/go-sqlite3(__DATA/__data): unexpected reloc for dynamic symbol munmap
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for close (type 32 rtype 1)
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for access (type 32 rtype 1)
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for getcwd (type 32 rtype 1)
github.com/mattn/go-sqlite3(__DATA/__data): unhandled relocation for stat$INODE64 (type 32 rtype 1)
too many errors

commented

did you read #92 ?

No and I just tried it, with CC=clang and CC unset to build the bindings:
marcmac:simple ms4720$ go install -x -ldflags -linkmode=external github.com/mattn/go-sqlite3

in both cases and then:
go run simple.go

and got the same dynamic linking errors, anything else you need to help? And thanks for the help.

commented

Hmm, I don' have osx, so i can't reproduce this. Currently, there are three issues that similar to this.

#92
#112
#115

I am using sqlite3 from mac ports if that is useful, specific version sqlite3 @3.8.10.1_0

commented

go-sqlite3 is static linked. so system library isn't dependent.

I have the same issue.

commented

did you try go install -x -ldflags -linkmode=external github.com/mattn/go-sqlite3?

unfortunately it does help. :(

commented

I don't make sure, but someone seems solved with this way.

#404

Seems like it works. thank you.