[postgis-users] shp2pgsql problems on Mac OS X Leopard

Patrick Hartling patrick.hartling at priority5.com
Wed Dec 5 08:32:07 PST 2007


I have run into a rather perplexing problem with shp2pgsql from  
PostGIS 1.3.1 and 1.3.2 on Mac OS X Leopard. As far as I can tell, the  
optarg and optind variables declared in ParseCmdline() of loader/ 
shp2pgsql.c are being linked to the globals declared in unistd.h  
rather than those in loader/getopt.h. The result is that references to  
these variables in ParseCmdline() give the wrong values. Specifically,  
optarg is always NULL, and optind is 0 until the loop in lines 1363  
through 1377.

Looking at the output from the preprocessor, optarg, optind, opterr,  
and optopt are all  declared twice. The first is from unistd.h, and  
the second is from PostGIS' loader/getopt.h. If I remove the #include  
directive for unistd.h, shp2pgsql compiles, links, and runs correctly,  
although there is a compiler warning saying that getopt() is not  
declared.

My guess is that there is some compiler or linker option that might  
fix this behavior, but I have not been able to determine what that  
might be. Removing the inclusion of unistd.h does not seem like the  
best fix, but it is a workaround that gets things running for me.

  -Patrick


--
Patrick L. Hartling
Senior Software Engineer, Priority 5
http://www.priority5.com/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20071205/f62d612c/attachment.pgp>


More information about the postgis-users mailing list