[GRASS5] GRASS binaries for Mac OS X

Glynn Clements glynn.clements at virgin.net
Mon Sep 22 19:39:10 EDT 2003


Markus Neteler wrote:

> I am still strying to compile GRASS 5.7 on Mac OSX.
> At time I face the general problem that, when compiling
> libraries, symbols from other GRASS libs are required.
> This doesn't happen on Linux.

Have you managed to get it working using static libraries? I recommend
trying that first, and only trying with dynamic libraries once you
have static libraries working.

> I solved this for some libs by adding e.g.
> EXTRA_LIBS=$(LIBLINK)
> etc to the Makefile. Like that the compile order is important
> and needs to be slightly modified. So far, so nice.
> 
> But in libgis I got stuck with
> 
> cd lib/gis
> make
> [...]
> OBJ.powerpc-apple-darwin6.6/writ_zeros.o OBJ.powerpc-apple-darwin6.6/yes.o
> OBJ.powerpc-apple-darwin6.6/zero.o OBJ.powerpc-apple-darwin6.6/zero_cell.o
> OBJ.powerpc-apple-darwin6.6/zone.o OBJ.powerpc-apple-darwin6.6/G_dump.o
> -lgrass_datetime -lz  -o
> /grass57exp/dist.powerpc-apple-darwin6.6/lib/libgrass_gis.dylib
> ld: Undefined symbols:
> _environ
> /usr/bin/libtool: internal link edit command failed
> make: *** [/grass57exp/dist.powerpc-apple-darwin6.6/lib/libgrass_gis.dylib]
> Error 1
> 
> The file 'putenv.c' from GRASS 5.3 should probably have
> #include <unistd.h>
> added as under Linux is defined:
> grep environ /usr/include/unistd.h
>   extern char **environ;
> 
> Unfortunately on Mac OSX there is nothing like that in
> /usr/include/unistd.h
> /usr/include/sys/unistd.h
> nor in another place.
> 
> How to solve that?

Just use putenv() instead of manually iterating through "environ".

The comment at the top of putenv.c says:

 * NOTE: this is a routine that UNIX should have provided, but didn't
 *       as such we are not yet sure of it's portability.

putenv() is specified by POSIX, so it should be available on all
Unix-like systems (unlike setenv(), which is a BSD-ism).

OTOH, the environ variable is also specified by POSIX. If OSX doesn't
provide it (or an equivalent), then it simply wouldn't be possible to
enumerate the list of environment variables (which would make
implementing the "env" command rather difficult).

I suppose that configure could be made to check for putenv();
G_putenv() would then use putenv if it is available, and its own
implementation (using environ) if it isn't (although the absence of
putenv() seems pretty unlikely to me).

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list