Linux中C++动态库编译的示例分析-创新互联
这篇文章主要介绍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
问题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
问题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
/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
/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
/home/thrift/protocol/TVirtualProtocol.h:401:55: required from ‘uint32_t apache::thrift::protocol::TVirtualProtocol
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
/home/thrift/protocol/TVirtualProtocol.h:405:55: required from ‘uint32_t apache::thrift::protocol::TVirtualProtocol
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
/home/thrift/protocol/TVirtualProtocol.h:499:54: required from ‘uint32_t apache::thrift::protocol::TVirtualProtocol
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
/home/thrift/protocol/TVirtualProtocol.h:503:54: required from ‘uint32_t apache::thrift::protocol::TVirtualProtocol
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++动态库编译的示例分析-创新互联
当前路径:http://pwwzsj.com/article/dpopjp.html