Hi Guys,
I am trying to write some code using the string class in C++ . Heres a segment of the code :-
Code:
#include <stdio.h>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string>
using std::string;
class Checksum
{
private:
struct tcphdr *tcp;
uint16_t temp_short;
uint32_t temp_long;
string hex_final;
public:
void init_header();
void decimaltohex();
};
Checksum check;
However when I compile it using gcc I get these errors:-
Code:
[root@localhost project]# gcc -o checksum checksum.cpp
/tmp/ccBQQu6W.o(.gnu.linkonce.t._ZN8ChecksumC1Ev+0x11): In function `Checksum::Checksum[in-charge]()':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string[in-charge]()'
/tmp/ccBQQu6W.o(.gnu.linkonce.t._ZN8ChecksumD1Ev+0x11): In function `Checksum::~Checksum [in-charge]()':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string [in-charge]()'
/tmp/ccBQQu6W.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
I'm guessing these are linking errors ; but havent a clue how to get around them.Any help is appreciated.
Thnx
Arvind