http://libtins.github.ioにあるlitbinsビルドパケットの例を試しています。C++ libtinsビルドエラー
私はインストール手順に従っており、#include <tins/tins.h>
でも問題ありません。この問題は実際にその機能を実際に参照しているようです。このクラスを構築しようとすると:
#include <tins/tins.h>
#include <cassert>
#include <iostream>
#include <string>
using namespace Tins;
int main() {
NetworkInterface iface = NetworkInterface::default_interface();
NetworkInterface::Info info = iface.addresses();
EthernetII eth("77:22:33:11:ad:ad", info.hw_addr);
eth /= IP("localhost", info.ip_addr);
eth /= TCP(13, 15);
eth /= RawPDU("I'm a payload!");
PacketSender sender;
sender.send(eth, iface);
}
私はこのエラーを取得する:NetBeansはC++ 11を使用している
cd '/home/oisin/NetBeansProjects/TCPPacket'
/usr/bin/gmake -f Makefile CONF=Debug
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory '/home/oisin/NetBeansProjects/TCPPacket'
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/tcppacket
gmake[2]: Entering directory '/home/oisin/NetBeansProjects/TCPPacket'
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/main.o.d"
g++ -c -g -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux
g++ -o dist/Debug/GNU-Linux/tcppacket build/Debug/GNU-Linux/main.o
build/Debug/GNU-Linux/main.o: In function `main':
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:26: undefined reference to `Tins::NetworkInterface::default_interface()'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:28: undefined reference to `Tins::NetworkInterface::addresses() const'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:30: undefined reference to `Tins::EthernetII::EthernetII(Tins::HWAddress<6ul, unsigned char> const&, Tins::HWAddress<6ul, unsigned char> const&)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:32: undefined reference to `Tins::IPv4Address::IPv4Address(char const*)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:32: undefined reference to `Tins::IP::IP(Tins::IPv4Address, Tins::IPv4Address)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:34: undefined reference to `Tins::TCP::TCP(unsigned short, unsigned short)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:36: undefined reference to `Tins::RawPDU::RawPDU(std::string const&)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:38: undefined reference to `Tins::PacketSender::DEFAULT_TIMEOUT'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:38: undefined reference to `Tins::NetworkInterface::NetworkInterface()'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:38: undefined reference to `Tins::PacketSender::PacketSender(Tins::NetworkInterface const&, unsigned int, unsigned int)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:40: undefined reference to `Tins::PacketSender::send(Tins::PDU&, Tins::NetworkInterface const&)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:38: undefined reference to `Tins::PacketSender::~PacketSender()'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:38: undefined reference to `Tins::PacketSender::~PacketSender()'
build/Debug/GNU-Linux/main.o: In function `Tins::EthernetII& Tins::operator/=<Tins::EthernetII>(Tins::EthernetII&, Tins::PDU const&)':
/usr/local/include/tins/pdu.h:537: undefined reference to `Tins::PDU::inner_pdu(Tins::PDU*)'
build/Debug/GNU-Linux/main.o: In function `Tins::EthernetII::~EthernetII()':
/usr/local/include/tins/ethernetII.h:46: undefined reference to `vtable for Tins::EthernetII'
/usr/local/include/tins/ethernetII.h:46: undefined reference to `Tins::PDU::~PDU()'
build/Debug/GNU-Linux/main.o: In function `Tins::IP::~IP()':
/usr/local/include/tins/ip.h:64: undefined reference to `vtable for Tins::IP'
/usr/local/include/tins/ip.h:64: undefined reference to `Tins::PDU::~PDU()'
build/Debug/GNU-Linux/main.o: In function `Tins::TCP::~TCP()':
/usr/local/include/tins/tcp.h:79: undefined reference to `vtable for Tins::TCP'
/usr/local/include/tins/tcp.h:79: undefined reference to `Tins::PDU::~PDU()'
build/Debug/GNU-Linux/main.o: In function `Tins::RawPDU::~RawPDU()':
/usr/local/include/tins/rawpdu.h:64: undefined reference to `vtable for Tins::RawPDU'
/usr/local/include/tins/rawpdu.h:64: undefined reference to `Tins::PDU::~PDU()'
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/GNU-Linux/tcppacket' failed
gmake[2]: *** [dist/Debug/GNU-Linux/tcppacket] Error 1
gmake[2]: Leaving directory '/home/oisin/NetBeansProjects/TCPPacket'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory '/home/oisin/NetBeansProjects/TCPPacket'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
gmake: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
、私は-DLIBTINS_ENABLE_CXX11=1
で++ 11のサポートCを有効にしていると私はしましたldconfig
を実行し、同じエラーをVMを再起動します。
私はこれらのエラーを取得するためにg++ main.cpp -o main -ltins
でクラスをリンクしようとした -
In file included from /usr/local/include/tins/tins.h:60:0,
from main.cpp:14:
/usr/local/include/tins/crypto.h:297:13: error: ‘function’ in namespace ‘std’ does not name a type
typedef std::function<void(const std::string&,
^
/usr/local/include/tins/crypto.h:308:13: error: ‘function’ in namespace ‘std’ does not name a 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_;
^
ヘルプは大歓迎。
EDIT
g++ app.cpp -o app -ltins -std=c++11
とmain.cpp
は、上記の問題を解決し、私のリンク、以下dvnguyenの答えに続き、今私は、次のエラーが残っている -
cd '/home/oisin/NetBeansProjects/TCPPacket'
/usr/bin/gmake -f Makefile CONF=Debug
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory '/home/oisin/NetBeansProjects/TCPPacket'
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/tcppacket
gmake[2]: Entering directory '/home/oisin/NetBeansProjects/TCPPacket'
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/main.o.d"
g++ -c -g -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux
g++ -o dist/Debug/GNU-Linux/tcppacket build/Debug/GNU-Linux/main.o -lmain
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lmain
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/GNU-Linux/tcppacket' failed
gmake[2]: *** [dist/Debug/GNU-Linux/tcppacket] Error 1
gmake[2]: Leaving directory '/home/oisin/NetBeansProjects/TCPPacket'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory '/home/oisin/NetBeansProjects/TCPPacket'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
gmake: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
私は本当に無知です私が行方不明になったもの
を - ログで更新質問を参照してください。 – xeon48
これはおそらくC++ 11型のためです。私はこれがうまくいくはずだと思います: – dvnguyen
g ++ app.cpp -o app -ltins -std = C++ 11 – dvnguyen