PHP Warning: Unable to load dynamic library – Here in this article, we will share some of the most common and frequently asked about PHP problem in programming with detailed answers and code samples. There’s nothing quite so frustrating as being faced with PHP errors and being unable to figure out what is preventing your website from functioning as it should like php and apache . If you have an existing PHP-based website or application that is experiencing performance issues, let’s get thinking about PHP Warning: Unable to load dynamic library.
Ok I have PHP working on my mac os x Apache 2 server.
Problem I am having is it can’t seem to find the extensions that allow me to connect to an sqlite database.
extension = php_sqlite.dll extension = php_pdo_sqlite.dll extension = php_sqlite3.dll
I get this error now that I have uncommented these extensions..
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_sqlite3.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_sqlite3.dll, 9): image not found in Unknown on line 0
It is the same error for all 3.
Now I have read in different places on the internet it could be that they aren’t installed on my mac, but I can’t find the PHP directory or anywhere where they would be!
I’m very new to this so any help would be grand
The DLL extension you’ve enabled are actually for Windows. On Mac and other *nix platforms, they’re actually SO files.
I’m on a Mac as well as it appears that the SQLite modules are already loaded. You should be able to comment out those lines in your
php.ini file, restart Apache and use SQLite without having to do anything. The SQLite modules have been included for as long as I can remember.
If it’s really not included, you’ll have to compile the modules from source. That requires that you install the Apple Developer Tools.
To compile from scratch (from the command line):
- Download the PHP’s source code. You’ll need to download the one that matches the version already installed on your system. To find out which one you’re using, type
php -vfrom the command line.
- Extract the archive you downloaded using
tar -zxvffollowed by the filename.
cd php-5.3.x/ext/sqlite3/(where “5.3.x” should be replaced with your version number and “sqlite3” can be any of the modules you want to install from your list above minus the “php_” prefix).
sudo make install.
php.ini(again make sure to replace sqlite3.so with the name of the other extensions if you compile the others).
Finally, restart Apache and you should be done.
Open php.ini. Look for the line that defines the location of your extensions. In my case (Windows machine), it goes like this:
extension_dir = "C:xamppphpext"
This gives you the location where all your extensions are located. Open it and check whether your SQLite extensions are indeed there.
Also, make sure your extensions are actually meant for a Mac computer. Their filename extension should be “dylib” or maybe “so” (not sure – I don’t have a Mac), while “dll” is a Windows-specific dynamic library filename extension (AFAIK).
Try removing and then reinstalling the packages:
brew rm mcrypt brew install mcrypt