簡體   English   中英

在Mac上鏈接到zeromq的已編譯版本時,發出編譯Go程序的問題

[英]Issue compiling Go program when linking to a compiled version of zeromq on Mac

我已經在Mac OSX 10.9.5上編譯了ZeroMQ,以便隨后使用github.com/pebbe/zmq4鏈接到一個簡單的Go程序,但是我遇到了這個錯誤,我不明白或不知道該如何解決。

# github.com/pebbe/zmq4
ld: warning: ignoring file /usr/local/lib/libzmq.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libzmq.dylib
Undefined symbols for architecture i386:
  "_zmq_bind", referenced from:
      __cgo_59814aec404b_C2func_zmq_bind in zmq4.cgo2.o
      __cgo_59814aec404b_Cfunc_zmq_bind in zmq4.cgo2.o
     (maybe you meant: __cgo_59814aec404b_Cfunc_zmq_bind, __cgo_59814aec404b_C2func_zmq_bind )
  "_zmq_close", referenced from:
      __cgo_59814aec404b_C2func_zmq_close in zmq4.cgo2.o
      __cgo_59814aec404b_Cfunc_zmq_close in zmq4.cgo2.o
     (maybe you meant: __cgo_59814aec404b_C2func_zmq_close, 
...
  "_zmq_z85_encode", referenced from:
      __cgo_59814aec404b_Cfunc_zmq_z85_encode in zmq4.cgo2.o
     (maybe you meant: __cgo_59814aec404b_Cfunc_zmq_z85_encode)
ld: symbol(s) not found for architecture i386
collect2: error: ld returned 1 exit status

我認為dylib是為x86_64(適用於Mac)制作的,但是Go為什么要嘗試與i386鏈接呢? 如何控制它並使其鏈接不同? 甚至是正確的?

如果您自己構建libzmq,請使用--disable-shared --enable-static密鑰進行配置。 如果您使用自制軟件,請卸載zmq並手動構建該庫。 如果您需要“胖”通用靜態庫,請使用以下腳本: https : //github.com/drewcrawford/libzmq-ios

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM