2 zijingshanke zijingshanke 于 2016.03.11 09:50 提问

Mac symbol(s) not found for architecture x86_64 ?
c mac

Mac编译 symbol(s) not found for architecture x86_64 ?修改

uname
Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
gcc -lncurses -o "veto_mq_server" ./src/veto_mq_server.o
Undefined symbols for architecture x86_64:
"_zmq_bind", referenced from:
_main in veto_mq_server.o
"_zmq_ctx_new", referenced from:
_main in veto_mq_server.o
"_zmq_recv", referenced from:
_main in veto_mq_server.o
"_zmq_send", referenced from:
_main in veto_mq_server.o
"_zmq_socket", referenced from:
_main in veto_mq_server.o
ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)
引用了第三方库ZMQ
/usr/local/include/
-rw-r--r--@ 1 root admin 844 Mar 10 15:00 zmq_utils.h

-rw-r--r--@ 1 root admin 16613 Mar 10 15:00 zmq.h
/usr/local/lib/
lrwxr-xr-x 1 yanrui admin 43 Mar 18 2015 libzmq.4.dylib -> ../Cellar/zeromq/4.0.5_2/lib/libzmq.4.dylib
-rwxr-xr-x 1 root admin 958 Mar 10 15:00 libzmq.la
lrwxr-xr-x 1 root admin 14 Mar 10 15:00 libzmq.dylib -> libzmq.5.dylib
-rw-r--r-- 1 root admin 23545352 Mar 10 15:00 libzmq.a
-rwxr-xr-x 1 root admin 602308 Mar 10 15:00 libzmq.5.dylib

图片说明

1个回答

zijingshanke
zijingshanke   2016.03.12 13:22
已采纳

gcc -L/usr/local/lib -o "veto_mq_server" ./src/veto_mq_server.o -lzmq

-L:第三方库路径
-l: 第三方库名称 形如libzmq.so,掐头去尾

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!