[GRASS5] GRASS 5.1: MacOSX compilation?

Currently I try to compile GRASS 5.1 on Mac OSX.

Thanks to the recent update of 'aclocal.m4' by Paul the
'configure' runs well now, using following parameters:
http://grass.itc.it/grass51/source/conf_scripts/macosx/
-> conf51_macOSX.sh

All libraries compile as well, but there is a problem
compiling modules (as well as some 'test' programs within
the libraries and the 'form' program). The compiler line
for linking modules seems to be wrong:

Example:

[timonchiotwin:~/grass51exp/raster/r.average] markus% make
gcc -I/Users/markus/grass51exp/include -I/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/include -I/usr/X11R6/include -I/sw/include -g -O2 -Wall -Wconversion -Wno-implicit-int -I/usr/X11R6/include -I/sw/include -I/Users/markus/grass51exp/include -I/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/include \
        -o OBJ.powerpc-apple-darwin6.6/main.o -c main.c
main.c: In function `main':
main.c:78: warning: suggest parentheses around assignment used as truth value
main.c:92: warning: suggest parentheses around assignment used as truth value
main.c:108: warning: passing arg 2 of `out' as floating rather than integer due to prototype
main.c:108: warning: passing arg 3 of `out' as floating rather than integer due to prototype
/usr/include/stdio.h: At top level:
/Users/markus/grass51exp/include/gis.h:36: warning: `GRASS_copyright' defined but not used
gcc -L/sw/lib -L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib -o /Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/etc/bin/cmd/r.average OBJ.powerpc-apple-darwin6.6/main.o -lgrass_gis -lgrass_datetime -lintl -lz
ld: /Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_gis.dylib is input for the dynamic link editor, is not relocatable by the static link editor again
ld: /Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_datetime.dylib is input for the dynamic link editor, is not relocatable by the static link editor again
make: *** [/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/etc/bin/cmd/r.average] Error 1

Knowing almost nothing about Mac OSX I would like to ask here for help.
Some 'gcc' flags seem to be missing.

Thanks

Markus

A followup:

it seems to be a problem of the libraries, not the modules.

file /Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_raster.dylib
/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_raster.dylib: Mach-O executable ppc

This is certainly wrong, obviously due to the use of
gcc -dylib
instead of
gcc -dynamiclib

(defined as: SHLIB_LD in aclocal.m4)

Changing this, I arrive at (tried with libgis):

[timonchiotwin:~/grass51exp/lib/gis] markus% make
gcc -L/sw/lib -L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib
        -dynamiclib -flat_namespace -fno_common -undefined suppress
        -L/sw/lib
        -L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib \
[...]
OBJ.powerpc-apple-darwin6.6/zone.o OBJ.powerpc-apple-darwin6.6/G_dump.o -o
/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_gis.dylib
ld: common symbols not allowed with MH_DYLIB output format
OBJ.powerpc-apple-darwin6.6/gisinit.o definition of common _G__ (size 142472)
OBJ.powerpc-apple-darwin6.6/geo_init.o definition of common _TABLE (size 86592)
OBJ.powerpc-apple-darwin6.6/gisinit.o definition of common _CELL_NODATA (size 4)
/usr/bin/libtool: internal link edit command failed
make: *** [/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_gis.dylib] Error 1

The parameters I was guessing from PROJ4 which compiles on Mac OSX, but
PROJ4 is using 'libtool'.

Still in the dark,

Markus

On Thu, Aug 21, 2003 at 11:00:46AM +0200, Markus Neteler wrote:

Currently I try to compile GRASS 5.1 on Mac OSX.

Thanks to the recent update of 'aclocal.m4' by Paul the
'configure' runs well now, using following parameters:
http://grass.itc.it/grass51/source/conf_scripts/macosx/
-> conf51_macOSX.sh

All libraries compile as well, but there is a problem
compiling modules (as well as some 'test' programs within
the libraries and the 'form' program). The compiler line
for linking modules seems to be wrong:

Example:

[timonchiotwin:~/grass51exp/raster/r.average] markus% make
gcc -I/Users/markus/grass51exp/include -I/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/include -I/usr/X11R6/include -I/sw/include -g -O2 -Wall -Wconversion -Wno-implicit-int -I/usr/X11R6/include -I/sw/include -I/Users/markus/grass51exp/include -I/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/include \
        -o OBJ.powerpc-apple-darwin6.6/main.o -c main.c
main.c: In function `main':
main.c:78: warning: suggest parentheses around assignment used as truth value
main.c:92: warning: suggest parentheses around assignment used as truth value
main.c:108: warning: passing arg 2 of `out' as floating rather than integer due to prototype
main.c:108: warning: passing arg 3 of `out' as floating rather than integer due to prototype
/usr/include/stdio.h: At top level:
/Users/markus/grass51exp/include/gis.h:36: warning: `GRASS_copyright' defined but not used
gcc -L/sw/lib -L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib -o /Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/etc/bin/cmd/r.average OBJ.powerpc-apple-darwin6.6/main.o -lgrass_gis -lgrass_datetime -lintl -lz
ld: /Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_gis.dylib is input for the dynamic link editor, is not relocatable by the static link editor again
ld: /Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_datetime.dylib is input for the dynamic link editor, is not relocatable by the static link editor again
make: *** [/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/etc/bin/cmd/r.average] Error 1

Knowing almost nothing about Mac OSX I would like to ask here for help.
Some 'gcc' flags seem to be missing.

Thanks

Markus

_______________________________________________
grass5 mailing list
grass5@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass5

Hello Markus

On Thu, 21 Aug 2003, Markus Neteler wrote:

...

Changing this, I arrive at (tried with libgis):

[timonchiotwin:~/grass51exp/lib/gis] markus% make
gcc -L/sw/lib -L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib
        -dynamiclib -flat_namespace -fno_common -undefined suppress
        -L/sw/lib
        -L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib \
[...]
OBJ.powerpc-apple-darwin6.6/zone.o OBJ.powerpc-apple-darwin6.6/G_dump.o -o
/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_gis.dylib
ld: common symbols not allowed with MH_DYLIB output format

What about deleting the '-fno-common' in the SHLIB_LD line? Perhaps this
is some kind of extra-strict warning that is not needed. But there might
be other consequences.

Paul

On Thu, Aug 21, 2003 at 11:32:58AM +0100, Paul Kelly wrote:

Hello Markus

On Thu, 21 Aug 2003, Markus Neteler wrote:

...
> Changing this, I arrive at (tried with libgis):
>
> [timonchiotwin:~/grass51exp/lib/gis] markus% make
> gcc -L/sw/lib -L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib
> -dynamiclib -flat_namespace -fno_common -undefined suppress
> -L/sw/lib
> -L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib \
> [...]
> OBJ.powerpc-apple-darwin6.6/zone.o OBJ.powerpc-apple-darwin6.6/G_dump.o -o
> /Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_gis.dylib
> ld: common symbols not allowed with MH_DYLIB output format

What about deleting the '-fno-common' in the SHLIB_LD line? Perhaps this
is some kind of extra-strict warning that is not needed. But there might
be other consequences.

I tried (sorry for the typo above in my message -fno-common was misspelled),
but omitting -fno-common does not change the result:

cd lib/gis
make clean
make
[...]
gcc -I/Users/markus/grass51exp/include
-I/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/include
-I/usr/X11R6/include -I/sw/include -g -O2 -Wall -Wconversion
-Wno-implicit-int -I/usr/X11R6/include -I/sw/include
-I/Users/markus/grass51exp/include
-I/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/include \
        -o OBJ.powerpc-apple-darwin6.6/zone.o -c zone.c /Users/markus/grass51exp/include/gis.h:36: warning: 'GRASS_copyright' defined but not used
gcc -I/Users/markus/grass51exp/include -I/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/include
-I/usr/X11R6/include -I/sw/include -g -O2 -Wall -Wconversion -Wno-implicit-int -I/usr/X11R6/include -I/sw/include
-I/Users/markus/grass51exp/include -I/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/include \
        -o OBJ.powerpc-apple-darwin6.6/G_dump.o -c G_dump.c
/Users/markus/grass51exp/include/gis.h:36: warning: 'GRASS_copyright' defined but not used
gcc -L/sw/lib -L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib
-dynamiclib -flat_namespace -undefined suppress -L/sw/lib
-L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib \
        OBJ.powerpc-apple-darwin6.6/adj_cellhd.o
OBJ.powerpc-apple-darwin6.6/align_window.o
OBJ.powerpc-apple-darwin6.6/alloc.o
[...]
OBJ.powerpc-apple-darwin6.6/zero_cell.o OBJ.powerpc-apple-darwin6.6/zone.o OBJ.powerpc-apple-darwin6.6/G_dump.o -o /Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_gis.dylib
ld: common symbols not allowed with MH_DYLIB output format
OBJ.powerpc-apple-darwin6.6/gisinit.o definition of common _G__ (size 142472)
OBJ.powerpc-apple-darwin6.6/geo_init.o definition of common _TABLE (size 86592)
OBJ.powerpc-apple-darwin6.6/gisinit.o definition of common _CELL_NODATA (size 4)
/usr/bin/libtool: internal link edit command failed
make: ***
[/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_gis.dylib]
Error 1

However, using -fno-common works e.g. for 'libgrass_datetime':
cd lib/datetime/
make
[...]
gcc -I/Users/markus/grass51exp/include
-I/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/include
-I/usr/X11R6/include -I/sw/include -g -O2 -Wall -Wconversion
-Wno-implicit-int -I/usr/X11R6/include -I/sw/include
-I/Users/markus/grass51exp/include
-I/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/include \
        -o OBJ.powerpc-apple-darwin6.6/values.o -c values.c
gcc -L/sw/lib -L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib
-dynamiclib -fno-common -flat_namespace
-undefined suppress -L/sw/lib
-L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib \
        OBJ.powerpc-apple-darwin6.6/between.o
OBJ.powerpc-apple-darwin6.6/copy.o OBJ.powerpc-apple-darwin6.6/same.o
OBJ.powerpc-apple-darwin6.6/diff.o OBJ.powerpc-apple-darwin6.6/error.o
OBJ.powerpc-apple-darwin6.6/format.o OBJ.powerpc-apple-darwin6.6/incr1.o
OBJ.powerpc-apple-darwin6.6/incr2.o OBJ.powerpc-apple-darwin6.6/incr3.o
OBJ.powerpc-apple-darwin6.6/local.o OBJ.powerpc-apple-darwin6.6/misc.o
OBJ.powerpc-apple-darwin6.6/change.o OBJ.powerpc-apple-darwin6.6/scan.o
OBJ.powerpc-apple-darwin6.6/sign.o OBJ.powerpc-apple-darwin6.6/type.o
OBJ.powerpc-apple-darwin6.6/tz1.o OBJ.powerpc-apple-darwin6.6/tz2.o
OBJ.powerpc-apple-darwin6.6/values.o -o
/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_datetime.dylib

Also fails libgrass_gmath.dylib
ld: common symbols not allowed with MH_DYLIB output format
OBJ.powerpc-apple-darwin6.6/del2g.o definition of common _g (size 8)
/usr/bin/libtool: internal link edit command failed
make: *** [/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_gmath.dylib]
Error 1

OK are:
- libgrass_bitmap.dylib
- libgrass_datetime.dylib
- libgrass_btree.dylib
- libgrass_gproj.dylib
and more, the modules also link successfully against these libs.

So probably the compilation flags are right, but something wrong in libgis?
Or another flag missing or a flag in the wrong position?

Markus

Hi again,

the *current* 5.1 CVS contains new updates to compile 5.1 on Mac OSX.
Run
make distclean
before re-trying.

Now all libraries compile except
lib/db/sqlp

gcc -fno-common -L/sw/lib
-L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib -dynamiclib
-flat_namespace
-undefined suppress -fno-common -L/sw/lib
-L/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib \
        OBJ.powerpc-apple-darwin6.6/alloc.o
OBJ.powerpc-apple-darwin6.6/print.o OBJ.powerpc-apple-darwin6.6/sql.o
OBJ.powerpc-apple-darwin6.6/lex.yy.o OBJ.powerpc-apple-darwin6.6/y.tab.o -o
/Users/markus/grass51exp/dist.powerpc-apple-darwin6.6/lib/libgrass_sqlp.dylib
ld: multiple definitions of symbol _sqlpStmt
OBJ.powerpc-apple-darwin6.6/alloc.o definition of _sqlpStmt in section (__DATA,__common)
OBJ.powerpc-apple-darwin6.6/print.o definition of _sqlpStmt in section (__DATA,__common)
OBJ.powerpc-apple-darwin6.6/sql.o definition of _sqlpStmt in section (__DATA,__common)
/usr/bin/libtool: internal link edit command failed

If I make sqlpStmt in
include/sqlp.h
extern, it compiles, but then fails in
db/drivers/dbf/

Same story there in db/drivers/dbf/ with
db
errMsg
drv_mode
variables. Should MAIN be defined somewhere? The same problem may apply to
Linux where 'gcc' seems to catch it somehow.

Markus

A follow-up (Mac OS X):

A google search showed that all problems with

ld: multiple definitions of symbol _XXXXXX

as e.g. in
display/d.colors/
ld: multiple definitions of symbol _signalflag
OBJ.powerpc-apple-darwin6.6/set_sigs.o definition of _signalflag in section (__DATA,__common)
OBJ.powerpc-apple-darwin6.6/sigint.o definition of _signalflag in section (__DATA,__common)

are to be solved with "extern" of the related variable.

http://www.blender.org/pipermail/bf-committers/2003-June/003289.html
http://archive.develooper.com/perl6-internals@perl.org/msg04323.html
etc.

I tried to fix that, but don't know enough about it.

All vector modules compile so far, most of the other modules as well.

Markus

Followup - GRASS 5.1 on Mac OS X (Darwin):

Finally after applying more patches to GRASS 5.0/5.1 (thanks
to Roberto Flor from IRST for his assistance) I was able
to compile GRASS 5.1 *completely* on Mac OS X (Darwin).

You need the latest (now or later) CVS versions:
- 5.0 CVS HEAD
- 5.1 CVS HEAD

A) To try at home from source code:

#fully clean 5.1:
cd /where/is/51
make mixclean
make distclean

#to catch the new 5.0 fixes from CVS HEAD:
cd /where/is/50
cvs up -dP

#now update 5.1:
cd /where/is/51
cvs up -dP

#example parameters here for configure:
# http://grass.itc.it/grass51/source/conf_scripts/macosx/conf51_macOSX.sh
configure -foo -bar ...

#link 5.0 code into 5.1:
make mix

#compile:
make
# ... report any problems...

#if successfull, install:
make install

grass51

B) Get precompiled binaries:

(Temporarily) download from:
http://mpa.itc.it/markus/grass51/macosx/
8MB to transfer as dynamic libraries are used

If these binaries are usable, I'll move them into the standard
web space on grass.itc.it (and mirrors). Let me know.

Thanks to Christian Tiso/University of Trento to let me use his
Mac OS X machine.

Cheers

Markus