[Proj] Help with multiply defined globals in Proj4 - Mac

Frank Warmerdam warmerdam at pobox.com
Thu Jun 24 21:48:29 EDT 2004


bsupnik wrote:
> Hi Y'all,
> 
> First of all, thanks Gerald Evenden, Niles Ritter and Frank Warmerdam 
> for libGeoTiff and Proj4...I'm working on decoding Geotiff images and 
> their coordiantes and they're a life saver, especially for UTM->geo 
> conversion.
> 
> Anyway, here's my compile issue...since I'm working in a Mac IDE I'm not 
> using the unix makefiles, which may be how I got into trouble:
> 
> geodesic.h defines a few global variables:
> 
> n_alpha, n_S;
>     double
> to_meter, fr_meter, del_alpha;
> 
> And is then included in multiple translation units.  Since they are not 
> externed and not initialized, my compiler can't tell which declaration 
> is the master one, and I am getting a duplicate definition link error.
> 
> What is the correct way to solve this?  Should I have all of the 
> translation units (geod_for.c, geod_inv.c, geod_set.c) or do I only need 
> some of them?  Should I simply declare them extern?

Ben,

The geodesic.h I have looks like this:

#ifndef _IN_GEOD_SET
#  define GEOD_EXTERN extern
#else
#  define GEOD_EXTERN
#endif

GEOD_EXTERN struct geodesic {
	double	A;
	double	LAM1, PHI1, ALPHA12;
	double	LAM2, PHI2, ALPHA21;
	double	DIST;
	double	ONEF, FLAT, FLAT2, FLAT4, FLAT64;
	int	ELLIPSE;
} GEODESIC;

...

GEOD_EXTERN int n_alpha, n_S;
GEOD_EXTERN double to_meter, fr_meter, del_alpha;

The geod_set.c module define _IN_GEOD_SET before includes geodesic.h.  This
should make all definitions of this stuff use "extern" except in the
geo_set.c module where they would be defined.  If you don't have the same
code then you are using old PROJ.4 code.  Substantial effort has gone into
making the PROJ.4 code compile on a wide variety of operating systems
in recent years.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Proj mailing list