这篇文章主要介绍Linux中C++动态库编译的示例分析,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
1 编译
问题1: configure:error: "Error: libcrypto required."
解决:apt-getinstall libssl-dev
问题2:uint32_tdoes not name a type
解决:
uint32_t定义文件在stdint.h,通过whereis stdint.h
stdint.h: /usr/include/stdint.h
说明在标准的include路径下,将出现编译错误的源码文件中添加#include<stdint.h>
问题3:Makefile文件的BOOST库路径指定错误
解决:
MakeFile文件中:BOOST_DIR = /usr/local/include/boost
而实际的情况却是:BOOST_DIR=/usr/include/boost
# apt-get installlibboost-dev
已经安装成功,但是不清楚安装的位置
查找本地boost库的安装目录:
whereis boost
boost:/usr/include/boost
问题 4:ntohs 存在未定义的编译错误
解决:
包含头文件#include<arpa/inet.h>
问题5:编译例子出现thrift库函数大量未定义的编译错误
解决:
主要是链接-lthrift必须放在CppClient.cppCppServer.cpp的后面,修改Makefile文件,调整两者的顺序即可。当某一个源码文件编译找不到函数定义的时候,只会往后查找函数定义
问题6:
解决:添加-DHAVE_NETINET_IN_H
In file included from /home/thrift/protocol/TBinaryProtocol.h:280:0,
from UploadMessageService_server.skeleton.cpp:5:
/home/thrift/protocol/TBinaryProtocol.tcc: In member function ‘uint32_t apache::thrift::protocol::TBinaryProtocolT<Transport_>::writeI16(int16_t)’:
/home/thrift/protocol/TBinaryProtocol.tcc:147:26: warning: there are no arguments to ‘htons’ that depend on a template parameter, so a declaration of ‘hton’ must be available [-fpermissive]
int16_t net = (int16_t)htons(i16);
^~~~~
/home/thrift/protocol/TBinaryProtocol.tcc: In member function ‘uint32_t apache::thrift::protocol::TBinaryProtocolT<Transport_>::writeI32(int32_t)’:
/home/thrift/protocol/TBinaryProtocol.tcc:154:26: warning: there are no arguments to ‘htonl’ that depend on a template parameter, so a declaration of ‘hton’ must be available [-fpermissive]
int32_t net = (int32_t)htonl(i32);
^~~~~
/home/thrift/protocol/TBinaryProtocol.tcc: In instantiation of ‘uint32_t apache::thrift::protocol::TBinaryProtocolT<Transport_>::writeI16(int16_t) [with Transport_ = apache::thrift::transport::TTransport; uint32_t = unsigned int; int16_t = short int]’:
/home/thrift/protocol/TVirtualProtocol.h:401:55: required from ‘uint32_t apache::thrift::protocol::TVirtualProtocol<Protocol_, Super_>::writeI16_virt(int16_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>; Super_ = apache::thrift::protocol::TProtocolDefaults; uint32_t = unsigned int; int16_t = short int]’
UploadMessageService_server.skeleton.cpp:89:1: required from here
/home/thrift/protocol/TBinaryProtocol.tcc:147:31: error: ‘htons’ was not declared in this scope
int16_t net = (int16_t)htons(i16);
~~~~~^~~~~
/home/thrift/protocol/TBinaryProtocol.tcc:147:31: note: suggested alternative: ‘htonll’
int16_t net = (int16_t)htons(i16);
~~~~~^~~~~
htonll
/home/thrift/protocol/TBinaryProtocol.tcc: In instantiation of ‘uint32_t apache::thrift::protocol::TBinaryProtocolT<Transport_>::writeI32(int32_t) [with Transport_ = apache::thrift::transport::TTransport; uint32_t = unsigned int; int32_t = int]’:
/home/thrift/protocol/TVirtualProtocol.h:405:55: required from ‘uint32_t apache::thrift::protocol::TVirtualProtocol<Protocol_, Super_>::writeI32_virt(int32_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>; Super_ = apache::thrift::protocol::TProtocolDefaults; uint32_t = unsigned int; int32_t = int]’
UploadMessageService_server.skeleton.cpp:89:1: required from here
/home/thrift/protocol/TBinaryProtocol.tcc:154:31: error: ‘htonl’ was not declared in this scope
int32_t net = (int32_t)htonl(i32);
~~~~~^~~~~
/home/thrift/protocol/TBinaryProtocol.tcc:154:31: note: suggested alternative: ‘htonll’
int32_t net = (int32_t)htonl(i32);
~~~~~^~~~~
htonll
In file included from /home/thrift/protocol/TBinaryProtocol.h:280:0,
from UploadMessageService_server.skeleton.cpp:5:
/home/thrift/protocol/TBinaryProtocol.tcc: In instantiation of ‘uint32_t apache::thrift::protocol::TBinaryProtocolT<Transport_>::readI16(int16_t&) [with Transport_ = apache::thrift::transport::TTransport; uint32_t = unsigned int; int16_t = short int]’:
/home/thrift/protocol/TVirtualProtocol.h:499:54: required from ‘uint32_t apache::thrift::protocol::TVirtualProtocol<Protocol_, Super_>::readI16_virt(int16_t&) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>; Super_ = apache::thrift::protocol::TProtocolDefaults; uint32_t = unsigned int; int16_t = short int]’
UploadMessageService_server.skeleton.cpp:89:1: required from here
/home/thrift/protocol/TBinaryProtocol.tcc:365:23: error: ‘ntohs’ was not declared in this scope
i16 = (int16_t)ntohs(theBytes.all);
~~~~~^~~~~~~~~~~~~~
/home/thrift/protocol/TBinaryProtocol.tcc:365:23: note: suggested alternative: ‘ntohll’
i16 = (int16_t)ntohs(theBytes.all);
~~~~~^~~~~~~~~~~~~~
ntohll
/home/thrift/protocol/TBinaryProtocol.tcc: In instantiation of ‘uint32_t apache::thrift::protocol::TBinaryProtocolT<Transport_>::readI32(int32_t&) [with Transport_ = apache::thrift::transport::TTransport; uint32_t = unsigned int; int32_t = int]’:
/home/thrift/protocol/TVirtualProtocol.h:503:54: required from ‘uint32_t apache::thrift::protocol::TVirtualProtocol<Protocol_, Super_>::readI32_virt(int32_t&) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>; Super_ = apache::thrift::protocol::TProtocolDefaults; uint32_t = unsigned int; int32_t = int]’
UploadMessageService_server.skeleton.cpp:89:1: required from here
/home/thrift/protocol/TBinaryProtocol.tcc:376:23: error: ‘ntohl’ was not declared in this scope
i32 = (int32_t)ntohl(theBytes.all);
~~~~~^~~~~~~~~~~~~~
/home/thrift/protocol/TBinaryProtocol.tcc:376:23: note: suggested alternative: ‘ntohll’
i32 = (int32_t)ntohl(theBytes.all);
以上是“Linux中C++动态库编译的示例分析”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
标题名称:Linux中C++动态库编译的示例分析-创新互联
转载来于:https://www.cdcxhl.com/article28/dpopjp.html
成都网站建设公司_创新互联,为您提供虚拟主机、网站维护、品牌网站制作、定制开发、小程序开发、Google
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联