Thanks for looking in the issue. I run the go build with the -x, but no where it is calling the gcc. Following is full output
WORK=/tmp/go-build815513256 mkdir -p $WORK/goresearch/mynet/_obj/ mkdir -p $WORK/goresearch/mynet/_obj/exe/ cd /home/administrator/GoWork/src/goresearch/mynet CGO_LDFLAGS="-g" "-O2" "-lm" "-ldl" "-lstdc++" "-ll" "-lc++" "-lc" "-lexslt" "-lgmalloc" "-lobjc" "-lpcap" "-lpthread" "-lSystem" "-ltls" "-lutil" "-lz" "-lxml2" /usr/lib/go-1.6/pkg/tool/linux_amd64/cgo -objdir $WORK/goresearch/mynet/_obj/ -importpath goresearch/mynet -- -I $WORK/goresearch/mynet/_obj/ -std=gnu99 mynet.go o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I $WORK/goresearch/mynet/_obj/ -g -O2 -std=gnu99 -o $WORK/goresearch/mynet/_obj/_cgo_main.o -c $WORK/goresearch/mynet/_obj/_cgo_main.c o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I $WORK/goresearch/mynet/_obj/ -g -O2 -std=gnu99 -o $WORK/goresearch/mynet/_obj/_cgo_export.o -c $WORK/goresearch/mynet/_obj/_cgo_export.c o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -I $WORK/goresearch/mynet/_obj/ -g -O2 -std=gnu99 -o $WORK/goresearch/mynet/_obj/mynet.cgo2.o -c $WORK/goresearch/mynet/_obj/mynet.cgo2.c o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -o $WORK/goresearch/mynet/_obj/_cgo_.o $WORK/goresearch/mynet/_obj/_cgo_main.o $WORK/goresearch/mynet/_obj/_cgo_export.o $WORK/goresearch/mynet/_obj/mynet.cgo2.o -g -O2 -lm -ldl -lstdc++ -ll -lc++ -lc -lexslt -lgmalloc -lobjc -lpcap -lpthread -lSystem -ltls -lutil -lz -lxml2 /usr/lib/go-1.6/pkg/tool/linux_amd64/cgo -objdir $WORK/goresearch/mynet/_obj/ -dynpackage main -dynimport $WORK/goresearch/mynet/_obj/_cgo_.o -dynout $WORK/goresearch/mynet/_obj/_cgo_import.go o64-clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -o $WORK/goresearch/mynet/_obj/_all.o $WORK/goresearch/mynet/_obj/_cgo_export.o $WORK/goresearch/mynet/_obj/mynet.cgo2.o -g -O2 -Wl,-r -nostdlib /usr/lib/go-1.6/pkg/tool/linux_amd64/compile -o $WORK/goresearch/mynet.a -trimpath $WORK -p main -buildid a01d97609ce6d71f052c7746576b9b68357f6099 -D _/home/administrator/GoWork/src/goresearch/mynet -I $WORK -pack $WORK/goresearch/mynet/_obj/_cgo_gotypes.go $WORK/goresearch/mynet/_obj/mynet.cgo1.go $WORK/goresearch/mynet/_obj/_cgo_import.go pack r $WORK/goresearch/mynet.a $WORK/goresearch/mynet/_obj/_all.o # internal cd . /usr/lib/go-1.6/pkg/tool/linux_amd64/link -o $WORK/goresearch/mynet/_obj/exe/a.out -L $WORK -extld=o64-clang -buildmode=exe -buildid=a01d97609ce6d71f052c7746576b9b68357f6099 -extld=o64-clang $WORK/goresearch/mynet.a # goresearch/mynet /usr/lib/go-1.6/pkg/tool/linux_amd64/link: running o64-clang failed: exit status 1 ld: warning: ignoring file /tmp/go-link-989097505/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-989097505/000001.o Undefined symbols for architecture x86_64: "_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) The above output states that it is creating the ELF file format, which it is not able to understand. I tried different linker options also, but did not succeed. On Thursday, January 5, 2017 at 9:07:27 PM UTC+5:30, Ian Lance Taylor wrote: > > On Thu, Jan 5, 2017 at 5:42 AM, Kedar Babar <kedar...@gmail.com > <javascript:>> 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.