4

我想在我的构建中链接 zeromq 库,这样它们就不必单独安装在最终用户的机器上。

我使用以下方法配置了 zeromq:

./configure --enable-static --disable-shared --prefix=/home/xx/out

但是当我这样做时:

g++ -o zclient zmqclient.o /home/xx/out/lib/libzmq.a

我收到链接错误:

Undefined                       first referenced
 symbol                             in file

recv                                /opt/zmq/out/lib/libzmq.a(libzmq_la-signaler.o)
send                                /opt/zmq/out/lib/libzmq.a(libzmq_la-signaler.o)
__xnet_connect                      /opt/zmq/out/lib/libzmq.a(libzmq_la-tcp_connecter.o)
__xnet_socket                       /opt/zmq/out/lib/libzmq.a(libzmq_la-ip.o)
__xnet_getsockopt                   /opt/zmq/out/lib/libzmq.a(libzmq_la-tcp_connecter.o)
accept                              /opt/zmq/out/lib/libzmq.a(libzmq_la-tcp_listener.o)
listen                              /opt/zmq/out/lib/libzmq.a(libzmq_la-tcp_listener.o)
uuid_generate                       /opt/zmq/out/lib/libzmq.a(libzmq_la-uuid.o)
setsockopt                          /opt/zmq/out/lib/libzmq.a(libzmq_la-tcp_listener.o)
getaddrinfo                         /opt/zmq/out/lib/libzmq.a(libzmq_la-ip.o)
freeaddrinfo                        /opt/zmq/out/lib/libzmq.a(libzmq_la-ip.o)
__xnet_socketpair                   /opt/zmq/out/lib/libzmq.a(libzmq_la-signaler.o)
__xnet_bind                         /opt/zmq/out/lib/libzmq.a(libzmq_la-tcp_listener.o)
uuid_unparse                        /opt/zmq/out/lib/libzmq.a(libzmq_la-uuid.o)
ld: fatal: symbol referencing errors. No output written to zclient
collect2: ld returned 1 exit status

谁能告诉我哪里出错了,或者为我提供替代方法?

谢谢!

4

1 回答 1

3

原来图书馆:

-lsocket -lnsl -luuid

在 linux 上是标准的,但在 solaris 上不是,需要像这样包含在 Makefile 中:

g++ -lsocket -lnsl -luuid  zmqclient.cpp /home/xx/out/lib/libzmq.a   -o zmqclient
于 2012-07-17T11:36:13.353 回答