[GRASS-dev] [GRASS GIS] #456: Undefined references when building grass 6.4 rc2

#456: Undefined references when building grass 6.4 rc2
-----------------------+----------------------------------------------------
Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Keywords: | Platform: Linux
      Cpu: x86-64 |
-----------------------+----------------------------------------------------
When building grass 6.4 rc2 with LDFLAGS="-Wl,--no-undefined", it
generates a lot of undefined references.

Please check following patch:
http://svn.mandriva.com/cgi-
bin/viewvc.cgi/packages/cooker/grass/current/SOURCES/grass-6.4.0-fix-
linkage.patch

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Comment (by neteler):

Please try attached patch, it correct the missing references (we use
variables for the references, not the hardcoded names). Fixed in 6.4.0svn,
6.4.svn. Work in progress for GRASS 7.

Markus

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: fixed | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Changes (by neteler):

  * status: new => closed
  * resolution: => fixed

Comment:

Fixed also in GRASS 7.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

On Fri, Jan 23, 2009 at 1:21 PM, GRASS GIS <trac@osgeo.org> wrote:

#456: Undefined references when building grass 6.4 rc2
Ticket URL: <http://trac.osgeo.org/grass/ticket/456&gt;

...

Fixed also in GRASS 7.

... except for this one:

gcc -shared -o /home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib/libgrass_cairodriver.7.0.svn.so
-L/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
-Wl,--no-undefined -Wl,--export-dynamic -L/usr/lib64
-Wl,-rpath-link,/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
  OBJ.x86_64-unknown-linux-gnu/Box.o
OBJ.x86_64-unknown-linux-gnu/Color.o
OBJ.x86_64-unknown-linux-gnu/Draw_bitmap.o
OBJ.x86_64-unknown-linux-gnu/Draw.o
OBJ.x86_64-unknown-linux-gnu/Driver.o
OBJ.x86_64-unknown-linux-gnu/Erase.o
OBJ.x86_64-unknown-linux-gnu/Graph.o
OBJ.x86_64-unknown-linux-gnu/Line_width.o
OBJ.x86_64-unknown-linux-gnu/Raster.o
OBJ.x86_64-unknown-linux-gnu/read_bmp.o
OBJ.x86_64-unknown-linux-gnu/read.o
OBJ.x86_64-unknown-linux-gnu/read_ppm.o
OBJ.x86_64-unknown-linux-gnu/read_xid.o
OBJ.x86_64-unknown-linux-gnu/Set_window.o
OBJ.x86_64-unknown-linux-gnu/Text.o
OBJ.x86_64-unknown-linux-gnu/write_bmp.o
OBJ.x86_64-unknown-linux-gnu/write.o
OBJ.x86_64-unknown-linux-gnu/write_ppm.o
OBJ.x86_64-unknown-linux-gnu/write_xid.o -lgrass_driver -lgrass_gis
-lgrass_datetime -lz -lfreetype -lgrass_gis -lgrass_datetime
-lz -lXrender -lcairo -lX11 -lm -lSM -lICE -lX11 && \
        (cd /home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib;
ln -f -s libgrass_cairodriver.7.0.svn.so
/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib/libgrass_cairodriver.so)
OBJ.x86_64-unknown-linux-gnu/Text.o: In function `fc_init':
/home/neteler/grass70/lib/cairodriver/Text.c:180: undefined reference
to `FcInit'
OBJ.x86_64-unknown-linux-gnu/Text.o: In function `set_font_fc':
/home/neteler/grass70/lib/cairodriver/Text.c:198: undefined reference
to `FcNameParse'
/home/neteler/grass70/lib/cairodriver/Text.c:199: undefined reference
to `FcDefaultSubstitute'
/home/neteler/grass70/lib/cairodriver/Text.c:200: undefined reference
to `FcConfigGetCurrent'
/home/neteler/grass70/lib/cairodriver/Text.c:200: undefined reference
to `FcConfigSubstitute'
/home/neteler/grass70/lib/cairodriver/Text.c:201: undefined reference
to `FcConfigGetCurrent'
/home/neteler/grass70/lib/cairodriver/Text.c:201: undefined reference
to `FcFontMatch'
OBJ.x86_64-unknown-linux-gnu/Text.o: In function `font_list_fc':
/home/neteler/grass70/lib/cairodriver/Text.c:217: undefined reference
to `FcPatternCreate'
/home/neteler/grass70/lib/cairodriver/Text.c:218: undefined reference
to `FcObjectSetBuild'
/home/neteler/grass70/lib/cairodriver/Text.c:219: undefined reference
to `FcFontList'
/home/neteler/grass70/lib/cairodriver/Text.c:228: undefined reference
to `FcPatternGetString'
/home/neteler/grass70/lib/cairodriver/Text.c:229: undefined reference
to `FcPatternGetString'
/home/neteler/grass70/lib/cairodriver/Text.c:240: undefined reference
to `FcObjectSetDestroy'
/home/neteler/grass70/lib/cairodriver/Text.c:241: undefined reference
to `FcPatternDestroy'
/home/neteler/grass70/lib/cairodriver/Text.c:242: undefined reference
to `FcFontSetDestroy'
collect2: ld returned 1 exit status
make: *** [/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib/libgrass_cairodriver.7.0.svn.so]
Error 1

Apparently CAIRO_HAS_FT_FONT isn't set as missing from include/config.h
if I understand the problem correctly.

Markus

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: reopened
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Changes (by fundawang):

  * status: closed => reopened
  * resolution: fixed =>

Comment:

gui/wxpython/nviz/Makefile

still missing -lstdc++

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: reopened
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Comment (by neteler):

Can you please test attached patch (backport from GRASS 7)?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: fixed | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Changes (by fundawang):

  * status: reopened => closed
  * resolution: => fixed

Comment:

yes. please commit it.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: reopened
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Changes (by glynn):

  * status: closed => reopened
  * resolution: fixed =>

Comment:

This error, and its "fix", are bogus.

EXTRA_LIBS should only include the libraries which are used directly by
the library or module being built. Indirect dependencies should be handled
by the *LIB variables in Grass.make.

I intend to revert r35550, but first I'll attempt to determine what the
problem actually is and whether some other fix is necessary.

More generally, it would have been preferable for the reporter to have
attached the error messages (or at least a representative sample of them),
rather than attaching a patch and expecting it to be applied without any
understanding of the problem (the fact that it actually happened here
indicates a defect in the development process).

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

Markus Neteler wrote:

On Fri, Jan 23, 2009 at 1:21 PM, GRASS GIS <trac@osgeo.org> wrote:
> #456: Undefined references when building grass 6.4 rc2
>Ticket URL: <http://trac.osgeo.org/grass/ticket/456&gt;
...
> Fixed also in GRASS 7.

... except for this one:

gcc -shared -o /home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib/libgrass_cairodriver.7.0.svn.so

/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib/libgrass_cairodriver.so)
OBJ.x86_64-unknown-linux-gnu/Text.o: In function `fc_init':
/home/neteler/grass70/lib/cairodriver/Text.c:180: undefined reference to `FcInit'

Apparently CAIRO_HAS_FT_FONT isn't set as missing from include/config.h
if I understand the problem correctly.

It isn't supposed to be set in <grass/config.h>, but in
<cairo-features.h>

This particular case isn't bogus, as cairodriver/Text.c uses
FontConfig directly, so it should be listed in the Makefile.

Unfortunately, there aren't any configure checks for it (and thus no
$(FCLIB) or similar that we can use); we just assume that if
CAIRO_HAS_FT_FONT is defined, then linking against cairo will pull in
FontConfig automatically.

I have opened ticket #459 for this specific issue.

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

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: reopened
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Comment (by fundawang):

just export LDFLAGS="-Wl,--no-undefined" before running configure, you'll
get all of the undefined references errors.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: reopened
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Comment (by neteler):

I used

{{{
MYCFLAGS="-g -Wall -fno-common"
MYCXXFLAGS="-g -Wall"
MYLDFLAGS="-Wl,--no-undefined"
LDFLAGS="$MYLDFLAGS" CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./configure
...
}}}

and could perfectly reproduce (and "fix" the problem).

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: reopened
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Comment (by neteler):

Replying to [comment:6 glynn]:
> More generally, it would have been preferable for the reporter to have
attached the error messages (or at least a representative sample of them),

All are looking like this:

{{{
gcc -shared -o /home/neteler/grass64/dist.x86_64-unknown-linux-
gnu/lib/libgrass_driver.6.5.svn.so -L/home/neteler/grass64/dist.x86_64-
unknown-linux-gnu/lib -Wl,--no-undefined -Wl,--export-dynamic
-L/usr/lib64 -Wl,-rpath-link,/home/neteler/grass64/dist.x86_64-unknown-
linux-gnu/lib OBJ.x86_64-unknown-linux-gnu/Bitmap.o OBJ.x86_64-unknown-
linux-gnu/Box.o OBJ.x86_64-unknown-linux-gnu/Client.o OBJ.x86_64-unknown-
linux-gnu/Color.o OBJ.x86_64-unknown-linux-gnu/Cont.o OBJ.x86_64-unknown-
linux-gnu/Draw.o OBJ.x86_64-unknown-linux-gnu/Erase.o OBJ.x86_64-unknown-
linux-gnu/Font.o OBJ.x86_64-unknown-linux-gnu/Get_location.o OBJ.x86_64-
unknown-linux-gnu/Get_t_box.o OBJ.x86_64-unknown-linux-gnu/Graph.o OBJ.
x86_64-unknown-linux-gnu/Line_width.o OBJ.x86_64-unknown-linux-gnu/Move.o
OBJ.x86_64-unknown-linux-gnu/Panel.o OBJ.x86_64-unknown-linux-
gnu/Polydots.o OBJ.x86_64-unknown-linux-gnu/Polyline.o OBJ.x86_64-unknown-
linux-gnu/Polygon.o OBJ.x86_64-unknown-linux-gnu/Raster.o OBJ.x86_64-
unknown-linux-gnu/Respond.o OBJ.x86_64-unknown-linux-gnu/Returns.o OBJ.
x86_64-unknown-linux-gnu/Set_window.o OBJ.x86_64-unknown-linux-gnu/Text.o
OBJ.x86_64-unknown-linux-gnu/Text_size.o OBJ.x86_64-unknown-linux-
gnu/Work.o OBJ.x86_64-unknown-linux-gnu/font2.o OBJ.x86_64-unknown-linux-
gnu/font_freetype.o OBJ.x86_64-unknown-linux-gnu/init.o OBJ.x86_64-
unknown-linux-gnu/pad.o OBJ.x86_64-unknown-linux-gnu/parse_ftcap.o OBJ.
x86_64-unknown-linux-gnu/text2.o OBJ.x86_64-unknown-linux-gnu/text3.o OBJ.
x86_64-unknown-linux-gnu/main.o OBJ.x86_64-unknown-linux-gnu/command.o
OBJ.x86_64-unknown-linux-gnu/connect_sock.o -lgrass_gis -lgrass_datetime
-lz -lfreetype && \
         (cd /home/neteler/grass64/dist.x86_64-unknown-linux-gnu/lib; ln -f
-s libgrass_driver.6.5.svn.so /home/neteler/grass64/dist.x86_64-unknown-
linux-gnu/lib/libgrass_driver.so)
OBJ.x86_64-unknown-linux-gnu/Polygon.o: In function `line':
/home/neteler/grass64/lib/driver/Polygon.c:54: undefined reference to
`floor'
OBJ.x86_64-unknown-linux-gnu/text2.o: In function `soft_text':
/home/neteler/grass64/lib/driver/text2.c:143: undefined reference to `sin'
/home/neteler/grass64/lib/driver/text2.c:144: undefined reference to `cos'
OBJ.x86_64-unknown-linux-gnu/text2.o: In function `onechar':
/home/neteler/grass64/lib/driver/text2.c:160: undefined reference to `sin'
/home/neteler/grass64/lib/driver/text2.c:161: undefined reference to `cos'
OBJ.x86_64-unknown-linux-gnu/text3.o: In function `set_matrix':
/home/neteler/grass64/lib/driver/text3.c:130: undefined reference to `cos'
/home/neteler/grass64/lib/driver/text3.c:131: undefined reference to `sin'
/home/neteler/grass64/lib/driver/text3.c:132: undefined reference to `sin'
/home/neteler/grass64/lib/driver/text3.c:133: undefined reference to `cos'
collect2: ld returned 1 exit status
make: *** [/home/neteler/grass64/dist.x86_64-unknown-linux-
gnu/lib/libgrass_driver.6.5.svn.so] Error 1
[neteler@host550 driver]$
}}}

The patch indicates the list of affected directories. Adding $(MATHLIB)
resolves it (maybe "resolves").

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

On Fri, Jan 23, 2009 at 6:01 PM, GRASS GIS <trac@osgeo.org> wrote:

#456: Undefined references when building grass 6.4 rc2
Changes (by glynn):
This error, and its "fix", are bogus.

EXTRA_LIBS should only include the libraries which are used directly by
the library or module being built.

Re bogus:

# example:
cd lib/driver/
grep 'sin(' text2.c
    double sinrot = sin(D2R(text_rotation));
    double sinrot = sin(D2R(text_rotation));

To me this looks like a direct dependency.

man sin
----------- snip ------------
SIN(3) Linux Programmer's Manual
NAME
       sin, sinf, sinl - sine function

SYNOPSIS
       #include <math.h>

       double sin(double x);
       float sinf(float x);
       long double sinl(long double x);

       Link with -lm.
...
----------- snap ------------

I followed the RTFM, please explain bogus.

Markus

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: reopened
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Comment (by glynn):

Replying to [comment:6 glynn]:
> This error, and its "fix", are bogus.

My mistake; the cairodriver change (the one which I tested) is bogus, but
the rest are legitimate (i.e. the library uses functions from the math
library directly).

However, I think that it's probably better to just add $(MATHLIB) to the
linking command in Shlib.make. Compile.make already do this for
executables (which is why it has never caused problems before), but not
for shared libraries.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: reopened
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Comment (by glynn):

Replying to [comment:10 glynn]:

> However, I think that it's probably better to just add $(MATHLIB) to the
linking command in Shlib.make.

Done in r35565. This probably shouldn't be back-ported due to the
divergence between 6.x and 7.0 build system.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:11&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: reopened
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Comment (by neteler):

Replying to [comment:10 glynn]:
> My mistake; the cairodriver change (the one which I tested) is bogus,
but the rest are legitimate (i.e. the library uses functions from the math
library directly).

How to deal with the cairodriver change in 6.4.x?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:12&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: reopened
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Comment (by glynn):

Replying to [comment:12 neteler]:

> > My mistake; the cairodriver change (the one which I tested) is bogus,
but the rest are legitimate (i.e. the library uses functions from the math
library directly).
>
> How to deal with the cairodriver change in 6.4.x?

For whatever reason, the 6.4 version of the change (r35549) didn't touch
lib/cairodriver/Makefile, so no change is required.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:13&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: fixed | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Changes (by neteler):

  * status: reopened => closed
  * resolution: => fixed

Comment:

OK, then I'll close the ticket as fixed.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:14&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: fixed | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Comment (by fundawang):

I've found a new underlinking problem with cairo:
http://svn.mandriva.com/cgi-
bin/viewvc.cgi/packages/cooker/grass/current/SOURCES/grass-6.4.0-linkage.patch

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:15&gt;
GRASS GIS <http://grass.osgeo.org>

#456: Undefined references when building grass 6.4 rc2
------------------------+---------------------------------------------------
  Reporter: fundawang | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: reopened
  Priority: major | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
------------------------+---------------------------------------------------
Changes (by fundawang):

  * status: closed => reopened
  * resolution: fixed =>

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/456#comment:16&gt;
GRASS GIS <http://grass.osgeo.org>