[mapserver-users] multiple symbols prob./ Perl on OS X/ summary and workaround.

Alex Rice alex_rice at arc.to
Thu Aug 15 12:27:23 PDT 2002


Since it's not unlikely other OS X/ Perl Mapscript developers 
will hit this bug (or have already)

On OS X I ran into the situation where Perl Mapscript and DBD::Pg 
(The PostgreSQL driver for DBI) both were statically linked with 
libpq.a (the PostgreSQL client library).

The symptom was that scripts using both of these modules 
(actually not just mapscript; any two Perl modules statically 
bound to libpq.a) will die with this output from dyld:

dyld: perl multiple definitions of symbol _DLAddHead
/Library/Perl/darwin/auto/mapscript/mapscript.bundle definition 
of _DLAddHead
/Library/Perl/darwin/auto/DBD/Pg/Pg.bundle definition of _DLAddHead

It's a mystery because all of these perl modules were compiled 
with -flat_namespace, which I thought was supposed to fix all 
this on OS X.

The workaround is to use the environment variable 
DYLD_FORCE_FLAT_NAMESPACE. You can set it with setenv in your 
shell before running your scripts, or use other Unix methods. 
Strangely enough the typical Perl way does not work as expected:

--
#!/usr/bin/perl
# set at compile time (but doesn't work as expected)
BEGIN { $ENV{'DYLD_FORCE_FLAT_NAMESPACE'} = 1; }

use mapscript;
use DBI;
--

Instead I am using Apache's SetEnv directive, since this is a CGI 
script that's being run:

<Directory "xxx/yyy">
     # prevent libpq.a symbol collisions between mapscript and DBI.
     SetEnv DYLD_FORCE_FLAT_NAMESPACE 1
</Directory>


Alex Rice, Software Developer
Architectural Research Consultants, Inc.
alex_rice at arc.to
alrice at swcp.com





More information about the MapServer-users mailing list