Compiling the PDO_4D extension in recent versions of PHP5

Are you running Ubuntu 12.04 LTS? Are you working in PHP5? Do you need to access 4D database hosted on an external server? Have you discovered that PDO_4D won't compile when downloaded via PECL? Have I narrowed this to 0.001% of the world yet? Still with me? Well! That is exciting.

Here is how you can compile and install PDO_4D:

# Install dependencies (You may need more)
sudo apt-get install php5-dev
# Get most recent copy of the code
svn checkout pdo_4d   
cd pdo_4d
# Prepare the PHP extension for compiling
# Fix problem with generated configure pointing to incorrect header location.
# See:
sed -i -e 's/php\//php5\//g' configure
# Configure the package to the system
./configure --with-pdo-4d
# Copy fourd.h to the main directory. Note: This is not the correct way to
# fix this problem, but it works to get the extension compiled.
cp lib4d_sql/fourd.h .
# Compile!
# Copy the extension to PHP's library
sudo make install
# Create php5 module configuration file
sudo sh -c "echo > /etc/php5/conf.d/pdo_4d.ini"
# Restart apache
sudo apache2ctl restart
# Check for PDO_4D in the PHP CLI Information
php -i | grep 4D

The last command should return something along the lines of

PDO drivers => 4D, mysql
PDO Driver for 4D => enabled
Provided by  => 4D (, and Alter Way (
This program makes use of the 4D SQL protocol: <br />4D v11 and up, Copyright (c) 2009 4D<img src="?=PDO_4D_LOGO_ID" align="right" alt="4D logo" border="0">

Wasn't that fun!?

Update 7/12/13: If you need to export/dump a 4D database to a MySQL formatted SQL file, this will help:


Thanks for posting this up. I'm part of that miniscule percentage that this would be useful for, so I appreciate you documenting all this. I am running into a bit of an issue, though, and I'm using Ubuntu 12.03. Everything worked up until the last few commands. The piping into mods-available gets me this error:

sh: 1: cannot create /etc/php5/mods-available/pdo_4d.ini: Directory nonexistent

and then for the next command, I get

sudo: php5enmod: command not found

Any ideas or leads on how to fix those would be greatly appreciated. Thanks so much.

Oh! Oops! Apparently I got confused after staring at this stuff for far too long. I've corrected the directions. php5enmod doesn't exist at all, I was mixing up php5.3 with php5.4. Haha! Let me know if you have any other issues. I'm happy to hear someone else is using this information. Thanks!

I've been using the 4d-mysqldump on my dev server and local machine for months without issue. Are you hoping to use it also?

Wow! What a response time! Thanks for your help. Yes, those new directions worked just fine. I'm now going to have to figure out my PDO connection string, and then see what I can do. This is very exciting, because the documentation for 4D is very lacking out there. I'll definitely have a look at 4d-mysqldump, too. Thanks again!

Ha! You are welcome. Honestly, you caught me on a good day. ;)

Add new comment