Trouble with my first test program...
From: Chris Fernandez <cfernandez@xxxxxxxxxxxxxxx>
Date: Tue, 26 Dec 2006 10:08:12 +0100

Hi I decided for fun to try to make a jabber bot, for this I decided to use the gloox library since seens have have more documentation than the rest c++ libs out there..
well I wrote this based on the examples..:


#include <gloox/client.h>
#include <gloox/messagehandler.h>
#include <gloox/presencehandler.h>
#include <gloox/connectionlistener.h>

using namespace gloox;

class Bot : public ConnectionListener, MessageHandler {

  public:
    void start();

    virtual void handleMessage(Stanza *stanza);

    virtual void onConnect();

    virtual bool onTLSConnect( const CertInfo& info );

    virtual void onDisconnect( ConnectionError e );

   private:
           Client *client;

   };

void Bot::start() {
     JID jid( "jid@server/resource" );
     client = new Client( jid, "password" );
     client->registerConnectionListener( this );
     client->registerMessageHandler( this );
     client->setInitialPriority( 5 );
     client->setAutoPresence( true );
     client->connect();
     }

void Bot::onConnect() {
       printf( "connected -- disconnecting...\n" );
       }

bool Bot::onTLSConnect( const CertInfo& info ) {
  // examine certificate info
}

void Bot::handleMessage(Stanza *stanza) {
Stanza *s = Stanza::createMessageStanza( stanza->from().full(), "hello world" );
      client->send( s );
      }

void Bot::onDisconnect( ConnectionError e ) {
      printf( "message_test: disconnected: %d\n", e );
      if( e == ConnAuthenticationFailed )
      printf( "auth failed. reason: %d\n", client->authError() );
      }


main() {
       Bot *lolo = new Bot();
      lolo->start();
       delete ( lolo );
       return 0;
       }



but.. when I compile  with:
g++ test2.cpp -o test
I get...
/tmp/ccW3K4hy.o: In function `Bot::handleMessage(gloox::Stanza*)':
test2.cpp:(.text+0x148c): undefined reference to `gloox::JID::full() const'
test2.cpp:(.text+0x14a1): undefined reference to `gloox::JID::JID(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' test2.cpp:(.text+0x14d0): undefined reference to `gloox::Stanza::createMessageStanza(gloox::JID const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, gloox::StanzaSubType, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
test2.cpp:(.text+0x14de): undefined reference to `gloox::JID::~JID()'
test2.cpp:(.text+0x14f1): undefined reference to `gloox::JID::~JID()'
/tmp/ccW3K4hy.o: In function `Bot::start()':
test2.cpp:(.text+0x169c): undefined reference to `gloox::JID::JID(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' test2.cpp:(.text+0x1746): undefined reference to `gloox::Client::Client(gloox::JID const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' test2.cpp:(.text+0x17a8): undefined reference to `gloox::ClientBase::registerConnectionListener(gloox::ConnectionListener*)' test2.cpp:(.text+0x17d8): undefined reference to `gloox::ClientBase::registerMessageHandler(gloox::MessageHandler*)' test2.cpp:(.text+0x17ee): undefined reference to `gloox::Client::setInitialPriority(int)' test2.cpp:(.text+0x181a): undefined reference to `gloox::ClientBase::connect(bool)'
test2.cpp:(.text+0x1825): undefined reference to `gloox::JID::~JID()'
test2.cpp:(.text+0x1838): undefined reference to `gloox::JID::~JID()'
collect2: ld returned 1 exit status


I'm using:
uname -a
Linux rek2 2.6.18-gentoo-r4 #1 SMP Sat Dec 16 02:05:13 CST 2006 i686 Intel(R) Pentium(R) 4 CPU 2.40GHz GenuineIntel GNU/Linux

g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/gcc-4.1.1-r1/work/gcc-4.1.1/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.1 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --disable-multilib --disable-libmudflap --disable-libssp --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.1.1 (Gentoo 4.1.1-r1)


Hope you guys can help me get started
Thanks



--
gloox-dev mailing list
to unsubscribe:
send a message with subject 'unsubscribe gloox-dev' to minimalist@xxxxxxxxxx