linux – 如何将项目(比如zeromq)构建为静态库并将其链接到我的
发布时间:2020-12-30 21:14:09 所属栏目:Linux 来源:网络整理
导读:我想在我的项目中使用zeroMQ 我运行如下配置将libaray构建到我的主文件夹中 ./configure --enable-static --disable-shared --prefix=/home/xx/out 然后我链接我的项目 gcc -o myproject x.c y.c /home/xx/out/libzmq.a 但仍有很多链接错误,如下所示: ../zm
我想在我的项目中使用zeroMQ
./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::allocator<char> >::~basic_string()' ../zmq/lib/libzmq.a(libzmq_la-ip.o): In function zmq::resolve_ip_hostname(sockaddr_storage*,char const*)': /home/sureone/share/zeromq-2.2.0/src/ip.cpp:314: undefined reference to std::basic_string<char,std::allocator<char> >::basic_string(char const*,uns ……….. 解决方法
由于ZeroMQ(显然)使用C,因此您需要使用适当的编译器驱动程序(在本例中为g)来链接它. 试试这个: gcc -c x.c y.c g++ -o myproject x.o y.o /home/xx/out/libzmq.a (编辑:晋中站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |