[GRASS-dev] New NVIZ compile error

Glynn Clements glynn at gclements.plus.com
Thu Oct 16 11:56:19 EDT 2008


William Kyngesburye wrote:

> > /home/neteler/grass64/dist.x86_64-unknown-linux-gnu/lib/ 
> > libgrass_ogsf.so:
> > undefined reference to `guess_format'
> > /home/neteler/grass64/dist.x86_64-unknown-linux-gnu/lib/ 
> > libgrass_ogsf.so:
> > undefined reference to `avpicture_get_size'
> > /home/neteler/grass64/dist.x86_64-unknown-linux-gnu/lib/ 
> > libgrass_ogsf.so:
> ...
> >
> > Could this be related to recent Mac changes? I didn't upgrade my  
> > Linux box..

The above are all related to FFMPEG.

> Have you always built with ffmpeg support?  That's what all those  
> symbols are from.  Odd that the ffmpeg libraries aren't included in  
> the nviz makefile.

Not really; NVIZ doesn't use FFMPEG. The OGSF library uses FFMPEG, and
lib/ogsf/Makefile has the correct flags. Or rather, it did prior to
r33887 (and still does in 7.0).

The problem is the use of ":=" in r33887. Whereas "=" assigns the RHS
literally (with any variable references left unexpanded), ":="
recursively expands any variable references in the RHS prior to
assignment.

At the point that the assignment occurs, none of the variables which
appear on the RHS have been defined (Lib.make isn't included until
later).

[Except for $(EXTRA_LIBS), but that evaluates to a bunch of other
variable references, none of which have been defined.]

The net result is that EXTRA_LIBS ends up empty. This doesn't cause
any problems when the OGSF library is built, but it will cause
problems when you try to link an executable (i.e. NVIZ) against it.

The code should have used either "=" or (preferably) "+=", e.g.:

	ifeq ($(OPENGL_X11),1)
	EXTRA_LIBS += $(XLIBPATH) $(OPENGLLIB) $(OPENGLULIB)
	else
	EXTRA_LIBS += $(OPENGLLIB) $(OPENGLULIB)
	endif

In general: don't use ":=" unless you have a particularly good reason
for doing so. If you do need to use ":=", you need to ensure that any
variables which are referenced (directly or indirectly) on the RHS
have already been defined.

Most of the time, "=" is the correct assignment operator. One of the
few valid reasons for using ":=" is if the RHS is an expensive
function call such as $(shell ...) or $(wildcard ...), where you want
to ensure that the function is only called once even if the variable
is referenced multiple times.

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


More information about the grass-dev mailing list