On Thu, Jan 5, 2017 at 5:42 AM, Kedar Babar <kedartba...@gmail.com> wrote: > > I had written a small go program, which refers the 'C' code, following > is the snippet > > package main > > /* > #include <netdb.h> > */ > import "C" > import "fmt" > > const cgoAddrInfoFlags = (C.AI_CANONNAME | C.AI_V4MAPPED | C.AI_ALL) & > C.AI_MASK > > func main() { > fmt.Println("Hello") > } > > When i build the above program, i get the below linking errors for the > target darwin/amd64. > /usr/lib/go-1.6/pkg/tool/linux_amd64/link: running o64-clang failed: exit > status 1 > ld: warning: ignoring file /tmp/go-link-601229876/000001.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): /tmp/go-link-601229876/000001.o > Undefined symbols for architecture x86_64: > "__cgo_wait_runtime_init_done", referenced from: > _callbackTrampoline in 000000.o > _stepTrampoline in 000000.o > _doneTrampoline in 000000.o > "_x_cgo_free", referenced from: > __cgo_free in go.o > "_x_cgo_init", referenced from: > __cgo_init in go.o > "_x_cgo_malloc", referenced from: > __cgo_malloc in go.o > "_x_cgo_notify_runtime_init_done", referenced from: > __cgo_notify_runtime_init_done in go.o > "_x_cgo_setenv", referenced from: > runtime._cgo_setenv in go.o > "_x_cgo_thread_start", referenced from: > __cgo_thread_start in go.o > "_x_cgo_unsetenv", referenced from: > runtime._cgo_unsetenv in go.o > ld: symbol(s) not found for architecture x86_64 > clang: error: linker command failed with exit code 1 (use -v to see > invocation) > > Following is the go command used to build the above stuff. > env CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=o64-clang go build -x -work > -ldflags="-extld=o64-clang"
I don't know what the problem is, but the first step is to look at the direct invocations of the C compiler in the `go build -x` output and make sure that they look right. Make sure that nothing is calling "gcc" directly. Make sure that the invocations of "o64-clang" have any required flags. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.