Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ms4720 opened this issue May 30, 2015 · 14 comments
Closed

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

ms4720 opened this issue May 30, 2015 · 14 comments

Comments

@ms4720
Copy link

ms4720 commented May 30, 2015

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

@ms4720
Copy link
Author

ms4720 commented May 31, 2015

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"

@ms4720
Copy link
Author

ms4720 commented May 31, 2015

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$

@mattn
Copy link
Owner

mattn commented Jun 1, 2015

Try with below?

$ export CC=clang

@ms4720
Copy link
Author

ms4720 commented Jun 1, 2015

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

@mattn
Copy link
Owner

mattn commented Jun 1, 2015

did you read #92 ?

@ms4720
Copy link
Author

ms4720 commented Jun 1, 2015

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.

@mattn
Copy link
Owner

mattn commented Jun 1, 2015

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

#92
#112
#115

@ms4720
Copy link
Author

ms4720 commented Jun 1, 2015

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

@mattn
Copy link
Owner

mattn commented Jun 2, 2015

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

@bgaifullin
Copy link

I have the same issue.

@mattn
Copy link
Owner

mattn commented Jun 5, 2017

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

@bgaifullin
Copy link

unfortunately it does help. :(

@mattn
Copy link
Owner

mattn commented Jun 6, 2017

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

#404

@bgaifullin
Copy link

Seems like it works. thank you.

gjrtimmer added a commit to gjrtimmer/go-sqlite3 that referenced this issue May 26, 2018
Compile Section Closes mattn#175
Compile Section Closes mattn#201
Compile Section Closes mattn#206
Compile Section Closes mattn#404
Compile Section Closes mattn#217
Compile Section Closes mattn#224
Compile Section Closes mattn#234
Compile Section Closes mattn#242
Feature table Closes mattn#255
Description Section Closes mattn#232
Golang:1.6 not supported Closes mattn#272
Golang:1.5 not supported + compilation section Closes mattn#283
usleep Implemented Closes mattn#285
FAQ Section Closes mattn#289
Compile Section closes mattn#295
FAQ Section Closes mattn#305
PR339 Closes mattn#318 mattn#321
Compilation Section Closes mattn#341
PR407 Closes mattn#364
Feature `sqlite_vtable` Closes mattn#393
Compile Section Closes mattn#416
sqlite_trace feature Closes mattn#433
Compilation Section Closes mattn#435
Compilation Section Closes mattn#443
Golang:1.6 Not Supported Closes mattn#445
Compilation Section Closes mattn#451
Compilation Section Closes mattn#467
Compilation Section Closes mattn#491
Compilation Section Closes mattn#495
Compilation Section Closes mattn#505
Compilation Section Closes mattn#557
Compilation Section Closes mattn#560
@mattn mattn closed this as completed in c9394b1 May 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants