Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

"MDBlite", or building without the hassle

John Nagle
2007-03-20
2013-05-01
  • John Nagle
    John Nagle
    2007-03-20

    After struggling with "configure" and the dependency problems on irrelevant software, I decided to try building the command-line MDBtools without using the build system.

    It turns out that this works quite well. I have two tiny makefiles, one to build "libmdb.a", for the "libmdb" directory, and one to build "mdb-export", "mdb-schema", and "mdb-tables", which are all you really need for data conversion.

    Everything is compiled with default gcc options on Fedora Core 6.  The programs work on a test .MDB file.

    There's still a dependency on glib2.0, but all the other dependencies have been removed. 

    Here's the main makefile.  Put this in "util"

    #
    #       Makefile for MDBlite -- MDBtools without the junk.
    #
    .SUFFIXES:
    .SUFFIXES: .c .o

    INCLUDE = -I ../../include -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include
    LIBS = ../libmdb/libmdb.a /usr/lib/libglib-2.0.a
    CC=gcc
    CFLAGS= $(INCLUDE)

    all: mdb-export mdb-tables mdb-schema

    libmdb:
            cd ../libmdb && $(MAKE)

    $(OBJ): %.o: %.c
            $(CC) -c $(CFLAGS) $< -o $@

    mdb-export: mdb-export.o $(OBJ) libmdb
            gcc  -o mdb-export mdb-export.o $(LIBS)

    mdb-tables: mdb-tables.o $(OBJ) libmdb
            gcc  -o mdb-tables mdb-tables.o $(LIBS)

    mdb-schema: mdb-schema.o $(OBJ) libmdb
            gcc  -o mdb-schema mdb-schema.o $(LIBS)

    clean:
            -rm *.o
            -rm mdb-export mdb-tables mdb-schema
    ==================================================
    And here's the library Makefile.  Put this in "libmdb"
    ==================================================

    #
    #       Makefile for MDBlite -- MDBtools without the junk.
    #
    .SUFFIXES:
    .SUFFIXES: .c .o

    SRC = backend.c dump.c iconv.c kkd.c map.c money.c  props.c stats.c worktable.c \ catalog.c data.c file.c index.c like.c mem.c options.c sargs.c table.c write.c

    OBJ = backend.o dump.o iconv.o kkd.o map.o money.o props.o stats.o worktable.o \ catalog.o data.o file.o index.o like.o mem.o options.o sargs.o table.o write.o

    INCLUDE = -I ../../include -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include

    TARGET = libmdb.a

    CC=gcc
    CFLAGS= $(INCLUDE)

    all: libmdb.a

    $(OBJ): %.o: %.c
            $(CC) -c $(CFLAGS) $< -o $@

    libmdb.a: $(OBJ)
            ld -r -o libmdb.a $(OBJ)

    clean:
            -rm *.o
            -rm $(TARGET)
    ==============================================
    Once you have both of these in place, just cd to the "util" directory and
    type "make".  Building takes under ten seconds.

    Enjoy!

     
    • I've done this almost the same way, but additionally removed the dependencies from glib (and therefore from iconv, gettext and others).
      All I've done is replacing some glib functions (which are just a handful of arrays and hash things) by an 'own' implementation. Drawback: I'm using C++ stl containers for that.
      The libmdb code is completely untouched, you just have to 'inject' another version of glib.h.
      Currently the job is only done for the core (libmdb) itself.
      Also, I believe that it only works for i386 32 bit architectures (some big/little endian and word length things are fix constants).

      For interest contact me at lehner@edv-buero-nospam-lehner.de
      (Remove the nospam-)

       
    • osvenskan
      osvenskan
      2008-06-09

      Thanks John, your instructions worked for me on OS X 10.5 using the source for mdbtools-0.6pre1.

      - I applied the fix mentioned here (which you referenced elsewhere):
      http://sourceforge.net/tracker/index.php?func=detail&aid=1563144&group_id=2294&atid=102294

      - I adjusted the paths in the makefiles (usr/include ==> /usr/local/include and /usr/lib ==> /usr/local/lib)

      - I edited the libglib reference in util/Makefile from libglib-2.0.a to libglib-2.0.dylib.

      With those changes I was able to compile and link and read some test databases.

       
    • Michael Mauch
      Michael Mauch
      2009-03-12

      Yes, thank you, John - with the help of your Makefiles I could compile the CVS version (from 2007) on RHEL 5.2. No way with the autobuild.sh, but with your Makefiles it was easy.