All pastes #3132 Raw Edit

kfogel

public text v1 · immutable
#3132 ·published 2004-12-18 00:28 UTC
rendered paste body
I'm getting an odd compilation error for a small test program I'm writing
that uses the SVN APIs.

##################### First, the error: #########################

$ make
gcc -I/usr/local/include/subversion-1 -I/usr/local/apache2/include -I/usr/local/BerkeleyDB.4.2/include -L/usr/local/apache2/lib -L/usr/local/lib -L/usr/lib -L/usr/local/BerkeleyDB.4.2/lib -lapr-0 -laprutil-0 -lsvn_fs_base-1 -lsvn_fs-1 -lsvn_fs_fs-1 -ldb \
            -static -static-libgcc -o make-txn make-txn.c
/tmp/ccyXksDe.o(.text+0x20): In function `main':
: undefined reference to `svn_pool_create_ex'
/tmp/ccyXksDe.o(.text+0x9d): In function `main':
: undefined reference to `svn_fs_open'
/tmp/ccyXksDe.o(.text+0xc2): In function `main':
: undefined reference to `svn_handle_error'
collect2: ld returned 1 exit status
make: *** [make-txn] Error 1
$ 

################## Next, my Makefile: ##################

all: make-txn

INC_PATHS=-I/usr/local/include/subversion-1    \
          -I/usr/local/apache2/include         \
          -I/usr/local/BerkeleyDB.4.2/include

LIB_PATHS=-L/usr/local/apache2/lib         \
          -L/usr/local/lib                 \
          -L/usr/lib                       \
          -L/usr/local/BerkeleyDB.4.2/lib

LIB_LINKS=-lapr-0 -laprutil-0 \
          -lsvn_subr-1 -lsvn_fs_base-1 -lsvn_fs-1 -lsvn_fs_fs-1 \
          -ldb

make-txn: make-txn.c
	gcc $(INC_PATHS) $(LIB_PATHS) $(LIB_LINKS) \
            -static -static-libgcc -o make-txn make-txn.c

##################### Last, the program itself: #########################

/* Make a Subversion txn in a repository, then exit, leaving the txn.
 * Usage:
 *
 *    $ ./make-txn REPOSITORY
 *    TXN_NAME
 *    $ 
 */

#include <stdio.h>
#include <svn_pools.h>
#include <svn_error.h>
#include <svn_fs.h>

int
main (int argc, char **argv)
{
  const char *repository;
  svn_error_t *err;
  svn_fs_t *fs;
  svn_fs_txn_t *txn;
  apr_pool_t *pool = svn_pool_create (NULL);

  if (argc != 2)
    {
      printf ("Usage:\n");
      printf ("\n");
      printf ("   $ ./make-txn REPOSITORY\n");
      printf ("   TXN_NAME\n");
      printf ("   $\n");
      printf ("\n");
    }

  repository = argv[1];

  err = svn_fs_open (&fs, repository, NULL, pool);
  if (err)
    svn_handle_error (err, stdout, 1);

  printf ("KFF: got to the end\n");

  return 0;
}