PHP Warning: Unable to load dynamic library
Asked Answered
S

3

6

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 Disco

Swingletree answered 29/6, 2011 at 15:50 Comment(5)
.dll files are for Windows. On a Mac it'd be something else (.so?)Ladykiller
Why does the mac one come with .dll in the php.ini file. Doesn't really make snese. Will try changing it to .so.Swingletree
because php is multi-platform and contains examples for most of them?Ladykiller
Ok apparently it still can't find them even though they have been installed into the correct places using @Francois method below.Still getting the same error as above! Please helpSwingletree
I'm not sure if it applies for you but for me pdo_sqlite and pdo_mysql were already enabled somehow. It warned me of them being duplicately enabled so I just left those uncommented.Mayonnaise
V
13

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):

  1. 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 -v from the command line.
  2. Extract the archive you downloaded using tar -zxvf followed by the filename.
  3. Type 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).
  4. Type phpize.
  5. Type ./configure.
  6. Type make.
  7. Type sudo make install.
  8. Add extension=sqlite3.so to your 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.

Volscian answered 29/6, 2011 at 16:5 Comment(7)
Ok I found where all the extensions were and there was only one in there. Have done what you have said got stuck when typing phpize. I get this..... Make sure that you run usr/bin/phpize' in the top level source directory of the moduleSwingletree
Found the problem its looking for a file called config.m4 but iv only got config0.m4?Swingletree
pdo_sqlite and sqlite contains the config.m4 but sqlite3 doesn't? Do i need the sqlite 3?Swingletree
@Disco S2 - I have done what I posted above, but for pcntl (process forking) which doesn't come with OS X's PHP. I don't use SQLite so I'm not sure about the config files. I just checked my installation and found that it was already installed and shared the steps I used in the past.Volscian
Well your method worked installing them into the correct place as I only had one extension in there before. However its still says it can't find them. I apprecitae your helpSwingletree
"The DLL extension you've enabled are actually for Windows. On Mac and other *nix platforms, they're actually SO files." - the first line explains it all.Antifriction
Ok for everyone that is having this problem here's what I did to resolve. @amphetmachine is right, .dll is for windows so we are looking for .so extensions. The above solution is perfect for what we need to do. Follow the answer and it will install it. However when you do you will then need to go back into the php.ini file and comment out the extension as it will say in the error file something like "this extension is already installed"Swingletree
P
0

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:\xampp\php\ext"

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).

Precocious answered 29/6, 2011 at 16:2 Comment(0)
M
0

Try removing and then reinstalling the packages:

brew rm mcrypt
brew install mcrypt
Monochromatic answered 19/6, 2018 at 3:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.