Opened 7 weeks ago

Last modified 6 weeks ago

#467 new defect

PHP: Unable to load dynamic library 'mapscript'

Reported by: a.labenne Owned by: Jeff McKenna
Priority: major Milestone: 5.2.0 release
Component: MS4W - Base Version: 5.0.0
Keywords: Cc:
Blocked By: Blocking:

Description

Hello,

We tried the experimental 5.2.0 release and we found a bug when testing the quickmap.php script. We have the following error :

Fatal error: Uncaught Error: Class "mapObj" not found in C:\ms4w\Apache\htdocs\quickmap.php on line 19

If we enable the error_log in PHP.ini there is the following error that show up :

[08-Jul-2025 08:04:26 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'mapscript' (tried: /ms4w/Apache/php/ext/mapscript (Le module spécifié est introuvable), /ms4w/Apache/php/ext/php_mapscript.dll (Le module spécifié est introuvable)) in Unknown on line 0
[08-Jul-2025 08:04:26 UTC] PHP Fatal error:  Uncaught Error: Class "mapObj" not found in C:\ms4w\Apache\htdocs\quickmap.php:19
Stack trace:
#0 {main}
  thrown in C:\ms4w\Apache\htdocs\quickmap.php on line 19

I verified and the php_mapscript.dll file exists in the searched location.

Do you have any clue for this kind of error ?

Regards,

Arnaud Labenne

Change History (3)

comment:1 by Jeff McKenna, 7 weeks ago

Thanks for this report. I can't reproduce this with the experimental version yet, but what is the response when you try this command below?

cd ms4w
setenv.bat
php -dextension=C:/ms4w/Apache/php/ext/php_mapscript.dll -r "echo msGetVersion();"

It should return the MapServer version information such as:

MapServer version 8.6.0-dev (MS4W 5.2.0) PROJ version 9.7 GDAL version 3.12 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=SVG_SYMBOLS SUPPORTS=SVGCAIRO SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=OGCAPI_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS SUPPORTS=PBF INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE INPUT=FLATGEOBUF

comment:2 by Jeff McKenna, 7 weeks ago

Also, be sure to run the /ms4w/tmp/VC_redist.x86.exe installer before testing the experimental 5.2.0

Last edited 7 weeks ago by Jeff McKenna (previous) (diff)

comment:3 by a.labenne, 6 weeks ago

Thanks for your reply.

I have run the VC_redist.x86.exe installer before testing. Try a fresh install but this does not fix my issue.

When running the command

php -dextension=C:/ms4w/Apache/php/ext/php_mapscript.dll -r "echo msGetVersion();"

I get the following error :

php : Le terme «php» n'est pas reconnu comme nom d'applet de commande, fonction, fichier de script ou programme
exécutable. Vérifiez l'orthographe du nom, ou si un chemin d'accès existe, vérifiez que le chemin d'accès est correct
et réessayez.
Au caractère Ligne:1 : 1
+ php -dextension=C:/ms4w/Apache/php/ext/php_mapscript.dll -r "echo msG ...
+ ~~~
    + CategoryInfo          : ObjectNotFound: (php:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

If I run it with php-cgi.exe I get this error :

PHP Warning:  PHP Startup: Unable to load dynamic library 'mapscript' (tried: /ms4w/Apache/php/ext/mapscript (Le module sp├®cifi├® est introuvable), /ms4w/Apache/php/ext/php_mapscript.dll (Le module sp├®cifi├® est introuvable)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'ogr' (tried: /ms4w/Apache/php/ext/ogr (Le module sp├®cifi├® est introuvable), /ms4w/Apache/php/ext/php_ogr.dll (Le module sp├®cifi├® est introuvable)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'C:/ms4w/Apache/php/ext/php_mapscript.dll' (tried: C:/ms4w/Apache/php/ext/php_mapscript.dll (Le module sp├®cifi├® est introuvable), /ms4w/Apache/php/ext/\php_C:/ms4w/Apache/php/ext/php_mapscript.dll.dll (Le module sp├®cifi├® est introuvable)) in Unknown on line 0
Error in argument 2, char 2: option not found r
Usage: php-cgi [-q] [-h] [-s] [-v] [-i] [-f <file>]
       php-cgi <file> [args...]
  -a               Run interactively
  -b <address:port>|<port> Bind Path for external FASTCGI Server mode
  -C               Do not chdir to the script's directory
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  -e               Generate extended information for debugger/profiler
  -f <file>        Parse <file>.  Implies `-q'
  -h               This help
  -i               PHP information
  -l               Syntax check only (lint)
  -m               Show compiled in modules
  -q               Quiet-mode.  Suppress HTTP Header output.
  -s               Display colour syntax highlighted source.
  -v               Version number
  -w               Display source with stripped comments and whitespace.
  -z <file>        Load Zend extension <file>.
  -T <count>       Measure execution time of script repeated <count> times.

Side note : I encounter another error during the installation :

PS C:\ms4w> .\apache-install.bat
Installing the 'Apache MS4W Web Server' service
The 'Apache MS4W Web Server' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
httpd: Syntax error on line 184 of C:/ms4w/Apache/conf/httpd.conf: Cannot load /ms4w/Apache/cgi-bin/mod_mapcache.dll into server: Le module sp\xe9cifi\xe9 est introuvable.
Le service Apache MS4W Web Server démarre.
Le service Apache MS4W Web Server n’a pas pu être lancé.

Une erreur spécifique à un service s’est produite : 1.

Vous obtiendrez une aide supplémentaire en entrant NET HELPMSG 3547.

Commenting the line in httpd.conf solved my issue

LoadModule mapcache_module "/ms4w/Apache/cgi-bin/mod_mapcache.dll"
Note: See TracTickets for help on using tickets.