Thread: active worlds sdk (first test bot)

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    2

    active worlds sdk (first test bot)

    hello all,

    i just begun with c++. and i'm using it for a program called activeworlds (www.activeworlds.com/sdk). you can login into aw with the sdk of aw.

    i want to write thing called a robot with c++ that can login to aw. on the aw help pages (see link above) i found an example code, but when i compile it i doesn't work. can somebody help me by telling what i'm doing wrong?

    the code:
    Code:
    #include "aw.h"
    #include <stdio.h>
    #include <stdlib.h>
    
    void handle_avatar_add (void);
    
    main (int argc, char *argv[])
    {
    
      int rc;
    
      /* check command line */
      if (argc < 3) {
        printf ("Usage: %s number password\n", argv[0]);
        exit (1);
      }
    
      /* initialize Active Worlds API */
      if (rc = aw_init (AW_BUILD)) {
        printf ("Unable to initialize API (reason %d)\n", rc);
        exit (1);
      }
    
      /* install handler for avatar_add event */
      aw_event_set (AW_EVENT_AVATAR_ADD, handle_avatar_add);
    
      /* create bot instance */
      if (rc = aw_create ("auth.activeworlds.com", 5702, 0)) {
        printf ("Unable to create bot instance (reason %d)\n", rc);
        exit (1);
      }
    
      /* log bot into the universe */
      aw_int_set (AW_LOGIN_OWNER, atoi (argv[1]));
      aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, argv[2]);
      aw_string_set (AW_LOGIN_APPLICATION, "SDK Sample Application #1");
      aw_string_set (AW_LOGIN_NAME, "GreeterBot");
      if (rc = aw_login ()) {
        printf ("Unable to login (reason %d)\n", rc);
        exit (1);
      }
    
      /* log bot into the world called "beta" */
      if (rc = aw_enter ("Beta")) {
        printf ("Unable to enter world (reason %d)\n", rc);
        exit (1);
      }
    
      /* announce our position in the world */
      aw_int_set (AW_MY_X, 1000); /* 1W */
      aw_int_set (AW_MY_Z, 1000); /* 1N */
      aw_int_set (AW_MY_YAW, 2250); /* face towards GZ */
      if (rc = aw_state_change ()) {
        printf ("Unable to change state (reason %d)\n", rc);
        exit (1);
      }
    
      /* main event loop */
      while (!aw_wait (-1))
        ;
    
      /* close everything down */
      aw_destroy ();
      aw_term ();
      return 0;
    
    }
    
    void handle_avatar_add (void)
    {
    
      char message[100];
    
      sprintf (message, "Hello %s", aw_string (AW_AVATAR_NAME));
      aw_say (message);
      /* log the event to the console */
      printf ("avatar_add: %s\n", aw_string (AW_AVATAR_NAME));
    
    }
    the error:
    Code:
    [Linker error] undefined reference to '_imp__aw_init'
    [Linker error] undefined reference to '_imp__aw_event_set'
    [Linker error] undefined reference to '_imp__aw_create'
    and so on...
    i hope someone understands it...
    and pardon me if i don't speak very well english :$

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Read about the bit on the front page about
    The core component of the SDK is the file aw.dll, .......
    You need to link your code with either of those libraries.

    If you don't know how to do that, you need to state your compiler.
    Basically, find out where in your compiler/IDE you specify additional libraries.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    2
    thanks for your help. i find out, with another friend, where in my compiler (borland's c++ builder enterprise trail ánd/ór dev=c++) i can link it, and it works! thank you very much, and i'll continue to test en program, thanks again!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Operator Overloading help
    By Bartosz in forum C++ Programming
    Replies: 2
    Last Post: 08-17-2005, 12:55 PM
  2. MSVC Template Constructor/Assignment Errors
    By LuckY in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:57 PM
  3. Why is my program freezing?
    By ShadowMetis in forum Windows Programming
    Replies: 8
    Last Post: 08-20-2004, 03:20 PM
  4. Question About Linker Errors In Dev-C++
    By ShadowMetis in forum C++ Programming
    Replies: 9
    Last Post: 08-18-2004, 08:42 PM