溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Linux中C++動(dòng)態(tài)庫編譯的示例分析

發(fā)布時(shí)間:2021-10-18 15:05:28 來源:億速云 閱讀:250 作者:小新 欄目:編程語言

這篇文章主要介紹Linux中C++動(dòng)態(tài)庫編譯的示例分析,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

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

說明在標(biāo)準(zhǔn)的include路徑下,將出現(xiàn)編譯錯(cuò)誤的源碼文件中添加#include<stdint.h>

問題3:Makefile文件的BOOST庫路徑指定錯(cuò)誤

解決:

MakeFile文件中:BOOST_DIR = /usr/local/include/boost

而實(shí)際的情況卻是:BOOST_DIR=/usr/include/boost

 # apt-get installlibboost-dev

已經(jīng)安裝成功,但是不清楚安裝的位置

查找本地boost庫的安裝目錄:

whereis boost

boost:/usr/include/boost

問題 4:ntohs 存在未定義的編譯錯(cuò)誤

解決:

包含頭文件#include<arpa/inet.h>

問題5:編譯例子出現(xiàn)thrift庫函數(shù)大量未定義的編譯錯(cuò)誤

解決:

主要是鏈接-lthrift必須放在CppClient.cppCppServer.cpp的后面,修改Makefile文件,調(diào)整兩者的順序即可。當(dāng)某一個(gè)源碼文件編譯找不到函數(shù)定義的時(shí)候,只會(huì)往后查找函數(shù)定義

問題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++動(dòng)態(tài)庫編譯的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI