[GRASS-dev] Re: r.viewshed ready for testing

Hi Will

On Mon, 4 Aug 2008, Will wrote:

Hi Paul,

So I got the trunk version of GRASS, and compiled it, but iostream and
r.terraflow gave me errors. As the instructions say, I tackled the iostream
error first, and I can't figure out what's wrong with it. Here is what I
get if I call make in grass_trunk/lib/iostream

cc -dynamiclib -compatibility_version 7.0 -current_version 7.0 -install_name

   ^^
GRASS is trying to use the C compiler to create the shared library - this worked on Linux so I didn't notice it but obviously that must have been just luck and it seems not to work on OS X. This clearly is something I need to look at and try to fix - none of the other libraries contain C++ code so this hasn't come up before.

For now we can probably work around it by creating a static library instead of a shared one. Can you try changing the line
default: lib
in lib/iostream/Makefile to
default: stlib
and let me know how you get on?

Paul

On Mon, 4 Aug 2008, Paul Kelly wrote:

Hi Will

On Mon, 4 Aug 2008, Will wrote:

Hi Paul,

So I got the trunk version of GRASS, and compiled it, but iostream and
r.terraflow gave me errors. As the instructions say, I tackled the iostream
error first, and I can't figure out what's wrong with it. Here is what I
get if I call make in grass_trunk/lib/iostream

cc -dynamiclib -compatibility_version 7.0 -current_version 7.0 -install_name

^^
GRASS is trying to use the C compiler to create the shared library - this worked on Linux so I didn't notice it but obviously that must have been just luck and it seems not to work on OS X. This clearly is something I need to look at and try to fix - none of the other libraries contain C++ code so this hasn't come up before.

For now we can probably work around it by creating a static library instead of a shared one. Can you try changing the line
default: lib
in lib/iostream/Makefile to
default: stlib
and let me know how you get on?

Sorry just tested this more thoroughly - it seems you will also need to edit include/Make/Grass.make.in and change
IOSTREAMDEP = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(IOSTREAM_LIBNAME)$(LIB_SUFFIX)
to
IOSTREAMDEP = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(IOSTREAM_LIBNAME)$(STLIB_SUFFIX)
and then rerun the configure script, in order for r.terraflow to compile properly.

Paul

Paul Kelly wrote:

> So I got the trunk version of GRASS, and compiled it, but iostream and
> r.terraflow gave me errors. As the instructions say, I tackled the iostream
> error first, and I can't figure out what's wrong with it. Here is what I
> get if I call make in grass_trunk/lib/iostream
>
> cc -dynamiclib -compatibility_version 7.0 -current_version 7.0 -install_name
   ^^
GRASS is trying to use the C compiler to create the shared library - this
worked on Linux so I didn't notice it but obviously that must have been
just luck and it seems not to work on OS X. This clearly is something I
need to look at and try to fix - none of the other libraries contain C++
code so this hasn't come up before.

Another issue with making IOStream a dynamic library is that
Shlib.make only adds $(SHLIB_CFLAGS) to CFLAGS, not to CXXFLAGS.

On Linux, this causes the code to be compiled without -fPIC, resulting
in:

  warning: creating a DT_TEXTREL in object.

Normally, this is just an efficiency issue (the library won't actually
be shared; each process will have a separate copy), but it won't work
on systems running SELinux (to perform relocation, the code segment
has to be modified, and SELinux won't let it regain execute permission
after it has been modified).

Also, the effect will vary between platforms. The Darwin case in
SC_CONFIG_FLAGS has:

      SHLIB_CFLAGS="-fno-common"

ISTR that this may be a necessity for building dynamic libraries on
that platform.

I'll commit a fix for this as soon as I have tested it.

--
Glynn Clements <glynn@gclements.plus.com>