0

I have been trying to run an example driver program given in the globus toolkit website. This is the program:

#include "globus_xio.h"

int main(int argc,char *argv[])
{
    globus_result_t                 res;
    char *                          driver_name;
    globus_xio_driver_t             driver;
    globus_xio_stack_t              stack;
    globus_xio_handle_t             handle;
    globus_size_t                   nbytes;
    char *                          contact_string = NULL;
    char                            buf[256];

    contact_string = argv[1];
    driver_name = argv[2];

    globus_module_activate(GLOBUS_XIO_MODULE);
    res = globus_xio_driver_load(driver_name,&driver);
    assert(res == GLOBUS_SUCCESS);

    res = globus_xio_stack_init(&stack, NULL);
    assert(res == GLOBUS_SUCCESS);
    res = globus_xio_stack_push_driver(stack, driver);
    assert(res == GLOBUS_SUCCESS);

    res = globus_xio_handle_create(&handle, stack);
    assert(res == GLOBUS_SUCCESS);

    res = globus_xio_open(handle, contact_string, NULL);
    assert(res == GLOBUS_SUCCESS);

    do
    {
        res = globus_xio_read(handle, buf, sizeof(buf) - 1, 1, &nbytes, NULL);
        if(nbytes > 0)
        {
            buf[nbytes] = '\0';
            fprintf(stderr, "%s", buf);
        }
    } while(res == GLOBUS_SUCCESS);

    globus_xio_close(handle, NULL);

    globus_module_deactivate(GLOBUS_XIO_MODULE);

    return 0;
}

When I compile this using the command
cc -I /usr/include/globus globus_xio_example.c
I get the following errors

/tmp/ccLMLlIi.o: In function `main':
globus_xio_example.c:(.text+0x57): undefined reference to `globus_i_xio_module'
globus_xio_example.c:(.text+0x5c): undefined reference to `globus_module_activate'
globus_xio_example.c:(.text+0x75): undefined reference to `globus_xio_driver_load'
globus_xio_example.c:(.text+0xb1): undefined reference to `globus_xio_stack_init'
globus_xio_example.c:(.text+0xf2): undefined reference to `globus_xio_stack_push_driver'
globus_xio_example.c:(.text+0x133): undefined reference to `globus_xio_handle_create'
globus_xio_example.c:(.text+0x179): undefined reference to `globus_xio_open'
globus_xio_example.c:(.text+0x1d1): undefined reference to `globus_xio_read'
globus_xio_example.c:(.text+0x22b): undefined reference to `globus_xio_close'
globus_xio_example.c:(.text+0x230): undefined reference to `globus_i_xio_module'
globus_xio_example.c:(.text+0x235): undefined reference to `globus_module_deactivate'
collect2: ld returned 1 exit status
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
Joseph John
  • 111
  • 1
  • 1
  • 4

2 Answers2

0

It appears that the command used to compile is insufficient:

cc -I /usr/include/globus globus_xio_example.c

Specifically, the linker process indicates that there are a number of symbols that could not be resolved. I suspect that the command used to compile is lacking directives as to which library(s) needs to be linked to resolve the undefined symbols.


HINT:
Use 'globus-makefile-header' to help determine library dependencies.

% globus-makefile-header -flavor=gcc32dbg globus_xio > header

Examine the contents of 'header' for appropriate makefile macros.
Include header in your makefile and use the needed makefile macros.

Mahonri Moriancumer
  • 5,993
  • 2
  • 18
  • 28
0

Try this gcc -I /usr/include/globus globus_xio_example.c -lglobus_xio -lglobus_common