6

我想在我的项目中使用 zeroMQ 并运行如下配置以将 libaray 构建到我的主文件夹中

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

然后我链接我的项目

gcc -o myproject x.c y.c /home/xx/out/libzmq.a

但仍然有很多链接错误,如下所示:

../zmq/lib/libzmq.a(libzmq_la-ip.o): In function zmq::resolve_ip_interface(sockaddr_storage*, unsigned int*, char const*)':
/home/sureone/share/zeromq-2.2.0/src/ip.cpp:221: undefined reference to std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/home/sureone/share/zeromq-2.2.0/src/ip.cpp:222: undefined reference to std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
../zmq/lib/libzmq.a(libzmq_la-ip.o): In function zmq::resolve_ip_hostname(sockaddr_storage*, unsigned int*, char const*)':
/home/sureone/share/zeromq-2.2.0/src/ip.cpp:314: undefined reference to std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, uns

............

4

1 回答 1

6

gcc -o myproject xc yc /home/xx/out/libzmq.a

由于 ZeroMQ(显然)使用 C++,因此您需要使用适当的编译器驱动程序(g++在这种情况下)来链接它。

尝试这个:

 gcc -c x.c y.c
 g++ -o myproject x.o y.o /home/xx/out/libzmq.a
于 2012-04-23T01:19:54.210 回答