Skip to content

corss compile failed from when build on a mac #560

Description

@log225

go env below :

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/cable/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/cable/workspace/go/"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/k0/0qkltxj92tx3f8jd8dqdsxp80000gn/T/go-build490249343=/tmp/go-build -gno-record-gcc-switches -fno-common"

and I input

CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build

the error is:

/usr/local/Cellar/go/1.10.1/libexec/pkg/tool/darwin_amd64/link: running gcc failed: exit status 1
clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]
ld: warning: ignoring file /var/folders/k0/0qkltxj92tx3f8jd8dqdsxp80000gn/T/go-link-890000680/go.o, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): /var/folders/k0/0qkltxj92tx3f8jd8dqdsxp80000gn/T/go-link-890000680/go.o
Undefined symbols for architecture x86_64:
  "__cgo_topofstack", referenced from:
      __cgo_145d76c7925b_Cfunc_sqlite3_backup_finish in 000001.o
      __cgo_145d76c7925b_Cfunc_sqlite3_backup_init in 000001.o
      __cgo_145d76c7925b_Cfunc_sqlite3_backup_pagecount in 000001.o
      __cgo_145d76c7925b_Cfunc_sqlite3_backup_remaining in 000001.o
      __cgo_145d76c7925b_Cfunc_sqlite3_backup_step in 000001.o
      __cgo_145d76c7925b_Cfunc_sqlite3_user_data in 000002.o
      __cgo_145d76c7925b_Cfunc_sqlite3_value_blob in 000002.o
      ...
  "__cgoexp_145d76c7925b_callbackTrampoline", referenced from:
      _callbackTrampoline in 000000.o
  "__cgoexp_145d76c7925b_commitHookTrampoline", referenced from:
      _commitHookTrampoline in 000000.o
  "__cgoexp_145d76c7925b_compareTrampoline", referenced from:
      _compareTrampoline in 000000.o
  "__cgoexp_145d76c7925b_doneTrampoline", referenced from:
      _doneTrampoline in 000000.o
  "__cgoexp_145d76c7925b_rollbackHookTrampoline", referenced from:
      _rollbackHookTrampoline in 000000.o
  "__cgoexp_145d76c7925b_stepTrampoline", referenced from:
      _stepTrampoline in 000000.o
  "__cgoexp_145d76c7925b_updateHookTrampoline", referenced from:
      _updateHookTrampoline in 000000.o
  "_crosscall2", referenced from:
      _callbackTrampoline in 000000.o
      _stepTrampoline in 000000.o
      _doneTrampoline in 000000.o
      _compareTrampoline in 000000.o
      _commitHookTrampoline in 000000.o
      _rollbackHookTrampoline in 000000.o
      _updateHookTrampoline in 000000.o
      ...
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have installed the gcc-4.8.1-for-linux64.dmg on my mac.
then I changed this line in sqlite3.go

#cgo CFLAGS: -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE=1 -DHAVE_USLEEP=1
#cgo !linux,!android CFLAGS: -DHAVE_PREAD64=1 -DHAVE_PWRITE64=1

but still error……

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions