Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load dynamic library 'php_libsodium'

I'm trying to install the libsodium php extension (https://pecl.php.net/package/libsodium/1.0.6/windows).

When I run php -m, libsodium shows up in the list. However, when I go to phpinfo, it is not listed.

I also noticed that apache is giving me the error: PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\xampp\\php\\ext\\php_libsodium.dll' - The specified module could not be found.\r\n in Unknown on line 0

I've checked multiple times and the file is definitely there and matches the correct architecture and thread safety, so I'm at a loss for what else could be causing this.

Any help would be appreciated.

like image 346
ChrCar627 Avatar asked Mar 08 '17 21:03

ChrCar627


3 Answers

In my experience, you can get the 'Unable to load dynamic library' message for a couple of different reasons:

  1. You have enabled a module in php.ini but PHP can't find the dll file (either it doesn't exist, or it is in the wrong directory).
  2. The dll file was compiled for the wrong architecture (32-bit vs 64-bit) or the wrong threading model (e.g. a thread-safe DLL being used on a non-thread-safe version of PHP).
  3. The dll has some dependencies that couldn't be found. For example, you may need some additional .dll files to be put in a location that PHP can find them (e.g. in the main PHP directory).

In your case, given that you indicate a difference between what PHP reports using php -m and phinfo() (presumably in a web page), #1 may be the cause. Extensions are looked for in the location specified by the extension_dir setting in php.ini. If this is a relative path, then it may resolve differently in the context of the web server than it does when running from the command-line.

like image 80
HappyDog Avatar answered Oct 21 '22 21:10

HappyDog


Try to install libsodium:

verify php and pecl php -v pecl version

If you have php7.X then: sudo pecl install -f libsodium

If you are inside a Docker container: pecl install -f libsodium

Add sodium.so extension to php.ini.

sudo echo "extension = sodium.so" > /etc/php/7.1/mods-available/sodium.ini sudo phpenmod sodium

Verify that extension was installed php -i | grep "sodium"

like image 44
juanzapatac Avatar answered Oct 21 '22 21:10

juanzapatac


Try copy xampp\php\libsodium.dll to xampp\apache\bin\libsodium.dll and restart apache. On XAMPP 8.0.5 me help.

like image 2
Ripper Avatar answered Oct 21 '22 23:10

Ripper