Search code examples
clinuxxml-rpc

problems compiling xmlrpc-c program


I'm trying out the examples in the xmlrpc-c documentation:

#include <stdio.h>
#include <xmlrpc.h>
#include <xmlrpc_server.h>
//#include <xmlrpc_server_abyss.h>
#include <xmlrpc_abyss.h>
#include <xmlrpc-c/base.h>
#include <xmlrpc-c/util.h>

static xmlrpc_value *
sample_add(xmlrpc_env *   const envP,
           xmlrpc_value * const paramArrayP, 
           void *         const serverContext) {

    xmlrpc_int32 x, y, z;

    /* Parse our argument array. */
    xmlrpc_decompose_value(envP, paramArrayP, "(ii)", &x, &y);
    if (envP->fault_occurred)
        return NULL;

    /* Add our two numbers. */
    z = x + y;

    /* Return our result. */
    return xmlrpc_build_value(envP, "i", z);
}



int 
main (int           const argc, 
      const char ** const argv) {

    xmlrpc_server_abyss_parms serverparm;
    xmlrpc_registry * registryP;
    xmlrpc_env env;

    xmlrpc_env_init(&env);

    registryP = xmlrpc_registry_new(&env);

    xmlrpc_registry_add_method(
        &env, registryP, NULL, "sample.add", &sample_add, NULL);

    serverparm.config_file_name = argv[1];
    serverparm.registryP = registryP;

    printf("Starting XML-RPC server...\n");

    xmlrpc_server_abyss(&env, &serverparm, XMLRPC_APSIZE(registryP));

    return 0;
}

I try to compile using gcc: gcc source.c

nohting fancy and I get: /tmp/ccfGuc6A.o: In function sample_add': source.c:(.text+0x38): undefined reference toxmlrpc_decompose_value' source.c:(.text+0x6d): undefined reference to xmlrpc_build_value' /tmp/ccfGuc6A.o: In functionmain': source.c:(.text+0x96): undefined reference to xmlrpc_env_init' source.c:(.text+0xa5): undefined reference toxmlrpc_registry_new' source.c:(.text+0xd8): undefined reference to xmlrpc_registry_add_method' source.c:(.text+0x117): undefined reference toxmlrpc_server_abyss' collect2: error: ld returned 1 exit status

these functions exist in the: /usr/include/xmlrpc-c/base.h whihc I have referenced:

include

I think I'm not passing the right options to link, I don't know how it's done though.

thanks


Solution

  • I believe that xml-rpc-c comes with a helper program, intended to help you get the linking right. Its documented here

    http://xmlrpc-c.sourceforge.net/doc/xmlrpc-c-config.html