I found this, which worked without GOPATH assumptions: 
https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/

On Monday, 1 October 2018 at 7:32:23 pm UTC+10 Ankit Gupta wrote:

> Tamas,
>
> I installed docker on mac and cross compiled using xgo like you suggested. 
> Worked perfectly. Thanks a lot!
>
>
> On Saturday, September 29, 2018 at 1:58:20 AM UTC+5:30, Tamás Gulácsi 
> wrote:
>>
>> 2018. szeptember 28., péntek 15:59:14 UTC+2 időpontban Ankit Gupta a 
>> következőt írta:
>>>
>>> Thanks Ian for responding. Can you point me as to how to get the cross 
>>> compiler. I am farely new to Mac.
>>>
>>> On Fri, 28 Sep 2018, 19:23 Ian Lance Taylor, <ia...@golang.org> wrote:
>>>
>>>> On Fri, Sep 28, 2018 at 2:08 AM, Ankit Gupta
>>>> <ankit.gu...@gmail.com> wrote:
>>>> >
>>>> > I am working with confluent-kafka-go library
>>>> > (https://github.com/confluentinc/confluent-kafka-go) which builds 
>>>> fine on
>>>> > the mac machine (mac OS 10.13.6) along with the code files I wrote. 
>>>> In order
>>>> > to deploy it on Linux server (Ubuntu 64 bit), I try this -
>>>> >
>>>> > $> CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build program.go
>>>> >
>>>> >
>>>> > I get below linking error -
>>>> >
>>>> >
>>>> > /usr/local/go/pkg/tool/darwin_amd64/link: running clang failed: exit 
>>>> status
>>>> > 1
>>>> >
>>>> > ld: warning: ignoring file
>>>> > 
>>>> /var/folders/fy/9ph54yjs6cq1kyxgs6cc9rvjvs6t0m/T/go-link-060577916/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/fy/9ph54yjs6cq1kyxgs6cc9rvjvs6t0m/T/go-link-060577916/go.o
>>>> >
>>>> > Undefined symbols for architecture x86_64:
>>>> >
>>>> >   "__cgo_topofstack", referenced from:
>>>> >
>>>> >       __cgo_f2fa82ea8f11_Cfunc_rd_kafka_conf_new in 000003.o
>>>> >
>>>> >       __cgo_f2fa82ea8f11_Cfunc_rd_kafka_conf_set in 000003.o
>>>> >
>>>> >       __cgo_f2fa82ea8f11_Cfunc_rd_kafka_topic_conf_new in 000003.o
>>>> >
>>>> >       __cgo_f2fa82ea8f11_Cfunc_rd_kafka_topic_conf_set in 000003.o
>>>> >
>>>> >       __cgo_f2fa82ea8f11_Cfunc__c_rdkafka_topic_partition_list_entry 
>>>> in
>>>> > 000004.o
>>>> >
>>>> >       __cgo_f2fa82ea8f11_Cfunc_rd_kafka_assign in 000004.o
>>>> >
>>>> >       __cgo_f2fa82ea8f11_Cfunc_rd_kafka_assignment in 000004.o
>>>> >
>>>> >       ...
>>>> >
>>>> >   "_main", referenced from:
>>>> >
>>>> >      implicit entry/start for main executable
>>>> >
>>>> >      (maybe you meant: 
>>>> __cgo_f2fa82ea8f11_Cfunc_rd_kafka_queue_get_main)
>>>> >
>>>> > ld: symbol(s) not found for architecture x86_64
>>>> >
>>>> > clang: error: linker command failed with exit code 1 (use -v to see
>>>> > invocation)
>>>> >
>>>> >
>>>> > It points to /var/folders which I am given to understand is a temp 
>>>> location
>>>> > in mac.
>>>> >
>>>> >
>>>> > Any ideas on how to fix it?
>>>>
>>>> When cross-compiling a Go program that uses cgo, you need to be using
>>>> a C cross-compiler.  It looks like you are using the native Darwin C
>>>> compiler.  You need a cross-compiler from Darwin to GNU/Linux.
>>>>
>>>> Ian
>>>>
>>>
>> Native compilation is much easier.
>> If you have Docker installed, https://github.com/karalabe/xgo can help a 
>> lot!
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0f0528b6-6e6f-45d1-8b3a-ddd674e24f00n%40googlegroups.com.

Reply via email to