资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

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::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::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::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::writeI16_virt(int16_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT; 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::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::writeI32_virt(int32_t) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT; 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::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::readI16_virt(int16_t&) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT; 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::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::readI32_virt(int32_t&) [with Protocol_ = apache::thrift::protocol::TBinaryProtocolT; 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++动态库编译的示例分析-创新互联
URL地址:http://cdkjz.cn/article/dpopjp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220