2016-09-19 12 views
2

libtinsライブラリを使用してネットワークトラフィックを盗聴しようとしています。そこで、tar.gzのライブラリをダウンロードしました。マニュアルに記載されているすべてのライブラリのコンパイルが完了しました。今コンパイルエラー:名前空間 'std'の 'function'がテンプレートタイプの名前ではありません。

、私は私の最初のサンプルプログラムをコンパイルしようとしている:

1 #include <iostream> 
    2 #include <tins/tins.h> 
    3 
    4 using namespace Tins; 
    5 
    6 bool callback(const PDU &pdu) { 
    7  const IP &ip = pdu.rfind_pdu<IP>(); // Find the IP layer 
    8  const TCP &tcp = pdu.rfind_pdu<TCP>(); // Find the TCP layer 
    9  std::cout << ip.src_addr() << ':' << tcp.sport() << " -> " 
10    << ip.dst_addr() << ':' << tcp.dport() << std::endl; 
11  return true; 
12 } 
13 
14 int main() { 
15  Sniffer("eth0").sniff_loop(callback); 
16 } 

私はそれをコンパイルしたい、私は次のエラーに直面します。

[email protected]:~/Desktop/Workspace/cpp_libtins$ g++ main.cpp -ltins 
In file included from /usr/local/include/tins/tins.h:60:0, 
       from main.cpp:2: 
/usr/local/include/tins/crypto.h:297:18: error: ‘function’ in namespace ‘std’ does not name a template type 
    typedef std::function<void(const std::string&, 
       ^
/usr/local/include/tins/crypto.h:308:18: error: ‘function’ in namespace ‘std’ does not name a template type 
    typedef std::function<void(const std::string&, 
       ^
/usr/local/include/tins/crypto.h:401:44: error: ‘handshake_captured_callback_type’ does not name a type 
    void handshake_captured_callback(const handshake_captured_callback_type& callback); 
              ^
/usr/local/include/tins/crypto.h:412:34: error: ‘ap_found_callback_type’ does not name a type 
    void ap_found_callback(const ap_found_callback_type& callback); 
           ^
/usr/local/include/tins/crypto.h:445:9: error: ‘handshake_captured_callback_type’ does not name a type 
     handshake_captured_callback_type handshake_captured_callback_; 
     ^
/usr/local/include/tins/crypto.h:446:9: error: ‘ap_found_callback_type’ does not name a type 
     ap_found_callback_type ap_found_callback_; 
     ^
[email protected]:~/Desktop/Workspace/cpp_libtins$ 

何が悪いのでしょうか?

私のコンパイラのバージョン

[email protected]:~/Desktop/Workspace/cpp_libtins$ g++ --version 
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609 
Copyright (C) 2015 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions. There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

[email protected]:~/Desktop/Workspace/cpp_libtins$ 
+0

あなたは '-std = C++ 11'フラグを見逃していますか?あなたのGCCバージョンは何ですか? –

+0

@πάνταῥε '' -std = C++ 11 'で試してみてください。しかし、何が起こっているのですか?どうして? – Abraham

+0

@DieterLücking:https://github.com/mfontanini/libtins/blob/master/include/tins/crypto.h –

答えて

6

あなたのGCCが6.0よりも古いですので、あなたが-std=c++11スイッチ、otherwise it is in C++03 modeを渡す必要があります。 C++ 03にはstd::functionがありませんでした。

関連する問題