How to compile mdbtools on Mac OS X 10.4 and 10.5

Update: MacPorts appears to have a working port of mdbtools now.

Prerequisites

You’ll need MacPorts, the mdbtools source, and a simple patch. Use macports to install glib2, libtool, and automake:

port install glib2 libtool automake

One commenter reported that he had to upgrade version 2.5.35 of flex. I had no trouble with the version of flex included with Leopard, viz. 2.5.33.

MDB Tools source

You can get the mdbtools source from CVS, via the instructions at the sourceforge site, and my patch here.

Alternatively, use a git repo I started because CVS makes baby Theanthropos cry:

git clone git://gitorious.org/mdbtools/mainline.git mdbtools

autogen.sh && make && make install

cd into the mdbtools directory and run autogen.sh Pass any configuration args to autogen.sh, and it will pass them along to configure. /usr/local is the default prefix. The options below set the install location, enable compilation of the mdb-sql tool, but not gmdb2, the Gnome MDB File Viewer and debugger.

./autogen.sh --prefix=/users/Matthew/local --enable-sql --disable-gmdb2
make
make install

Assume that make and install work: you can test the results like so:

mdb-ver /path/to/thingy.mdb
mdb-tables /path/to/thingy.mdb
mdb-schema /path/to/thingy.mdb

29 comments:

Stockli said...

Fantastic... Thanks very much for taking the time to post your patch. I'm sure I would have wasted a lot of time trying to figure this out!

Matthew King said...

You're welcome. Allow me to commiserate with you on it's being necessary.

michael bedward said...

Hail to thee Matthew ! Just got mdbtools working under OSX 10.4.8. This will save me a heap of time. I'm pathetically grateful.

Peter Boye said...
This post has been removed by the author.
Peter Boye said...

Running autogen.sh, I get the error: "config.status: error: cannot find input file: Makefile.in"

What do I do wrong?

Matthew King said...

Peter, are you using the git repo, or the CVS + patch?

Peter Boye said...

I use the CVS, 0.6pre1. But I don't understand when to use the patch. Maybe that's the problem.

How do I utilise the git repo?

Matthew King said...

Peter:

You'll need git installed, which you can do with macports for sure, and probably fink. With macports, you do something like:

$ sudo port install git-core +svn

The "+svn" part gets you the git-svn tools, which allow near-seamless tracking of Subversion repos

Once you have git installed, cd to the directory where you want to keep mdb-tools source and start following my instructions where it says "git clone ..."

Hugh Cayless said...

I too am pathetically grateful. Had this working months ago, but I had to reinstall recently and lost it in the process, along with all memory of how I got it to build in the first place.

Thank you, thank you, thank you!

Mark said...

Thanks for sharing this information. It's been very helpful for me.

A small note: I followed the instructions and used GIT to get the sourcecode. The only problem I encountered when typing 'make' was an error about an 'invalid token character' or something.

After a bit of Google searching I found that this error was due to a bug in flex. Upgrading flex to 2.5.35 fixed it.

Hope this information helps someone else.

Matthew King said...

Thanks for the information, Mark. I made a note in the main article.

Linker3000 said...

Can I use git to grab the code for a build on CentOS 5 or is the code Mac-specific.

cvs made you cry - it's making me stabby!

Thanks

Matthew King said...

Linker3000, I can't remember whether I tested the changes on any Linux. Looking at the patch, though, the changes seem pretty straightforward, and not Mac specific. So the git repo should be at least a decent starting point.

Linker3000 said...

Thanks Matthew,

As it happens I managed to checkout the code from cvs eventually (2 days of trying!) and got it to compile OK.

L3K

k-mac said...

Don't know what I'm doing wrong.
Have done port install glib2 libtool automke

Downloaded the sources 0.5 and 0.6pre1.

Wanted to follow your instructions, but where is autogen.sh? It's not in the mdbtools-folder, nor anywhere in the system.

OSX 10.5.4 :(
Isn't there a working copy of the tools for osx out in the world without compiling, installing a bunch of macports and so forth?

k-mac said...

was a comment typo. meant
port install glib2 libtool automake

of course.

btw: doing a simple configure with the options above + make, I get an error:
ld: duplicate symbol _mdb_backends in mem.lo and catalog.lo

collect2: ld returned 1 exit status
make[2]: *** [libmdb.la] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

Matthew King said...

k-mac:

I don't think I ever tried the release packages. I went straight to the CVS repo. Have you tried the Git repo I published?

k-mac said...

Well, don't know about git. Have tried a
port install git-core +svn
like it was written somewhere, but I get
---> Fetching p5-error
---> Attempting to fetch Error-0.17012.tar.gz from (several servers, none working).
So I don't have that thing called "git".

Have downloaded the cvs repo and fouznd a autogen.sh which I could patch. Done so, I tried a ./autogen.sh, but got the following error:

checking Are we using flex ... yes
./configure: line 20350: syntax error near unexpected token `2.0.0'
./configure: line 20350: `AM_PATH_GLIB_2_0(2.0.0)'

looking up I found a message at the very beginning, saying:
# ./autogen.sh
**Warning**: I am going to run `configure' with no arguments.
If you wish to pass any to it, please specify them on the
`./autogen.sh' command line.

processing .
Running aclocal ...
configure.in:106: warning: macro `AM_PATH_GLIB_2_0' not found in library
Running libtoolize...
... and so forth

Also tried with --enable-sql --disable-gmdb2
no changes

k-mac said...

Finally I got git installed. Had to patch the Portfile of p5-error to use the Version 17015 rather than 17012 cos I found out that 012 was no longer on the servers.
Than I had to make a port install git-core without +svn. The latter brought me other errors building sqlite3.

Than I did the git command you posted which gave me another mdbtools folder where I could start autogen.sh
...
leading to exactly the same error message as in my previous post
./configure: line 20350: syntax error near unexpected token `2.0.0'
./configure: line 20350: `AM_PATH_GLIB_2_0(2.0.0)'

:(

Looks like mdbtools are not made for the mac. Damned there is no alternative out in the world.
Trying to find a osx binary version of the tools, but whyever noone leaves them for download.

Matthew King said...

k-mac, I am perplexed.

I cloned the git repo anew, then ran autogen.sh, receiving no errors. The configure file that was produced does not have the string "AM_PATH_GLIB_2_0" anywhere in it. I don't know much about automake, but it seems that AM_PATH_GLIB_2_0 is a macro that shouldn't be showing up in your configure file.

My best guess is that something is wrong with your automake/autoconf system.

Jim Benton said...

k-mac, sounds like automake isn't installed. You need to run:

sudo port install automake

Greg said...

@k-mac

Have you checked to see which version of automake is being used with:

which automake

most likely there is another version somewhere else that is being used. To solve the problem temporarily, you can put your mac ports path at the front of your path eg:

PATH=/opt/local/bin:$PATH

before you run autogen.sh

mars said...

Just got this working as per instructions,
using the SF CVS repo and OS X 10.5.5.

I also had to get gawk for the man pages to install: port install gawk

thanks!

Anonymous said...

Hello,

Thanks for all this very helpful information. Just FYI, the pastie.org link for your patch seems to have gotten fouled somehow.. it links to what looks like diff output, instead of a complete shell script. For the convenience of others, I re-posted the intact version from your git archive: http://pastie.org/492955

Justin said...

I just thought I'd post and say that the PECL extension mdbtools successfully installed with the patched version of mdbtools that you provide. Thank you.

Matthew King said...

Justin, that's great. Glad that it's helping the poor souls who must work with Access. Wyrd has decreed that I no longer must suffer so.

Anonymous said...

$ sudo bash
Password:
# port install mdbtools
---> Fetching mdbtools
---> Attempting to fetch mdbtools-0.6pre1.tar.gz from http://internap.dl.sourceforge.net/mdbtools
---> Verifying checksum(s) for mdbtools
---> Extracting mdbtools
---> Applying patches to mdbtools
---> Configuring mdbtools
---> Building mdbtools
---> Staging mdbtools into destroot
---> Installing mdbtools @0.6pre1_0
---> Activating mdbtools @0.6pre1_0
---> Cleaning mdbtools
#

Matthew King said...

Hooray for MacPorts.

viatropos said...

Awesome! MacPorts installed mdbtools perfectly. I'm having some trouble and am hoping you might have some advice.

When I run mdb-tables mydata.mdb, it returns nothing, or an empty array with ActiveMDB. When I run mdb-ver mydata.mdb, it says "JET4", which looks like it's from Jet 4 Access 2000. The mydata.mdb file is 80MB and if I open it, I can see some of the data amongst all the crazy characters.

Why might this not be returning any tables? Any ideas?