[GRASS-dev] lib/pngdriver Mingw compile error
Paul Kelly
paul-grass at stjohnspoint.co.uk
Tue Oct 31 04:40:55 EST 2006
On Tue, 31 Oct 2006, Glynn Clements wrote:
>> OBJ.i686-pc-mingw32/Color_table.o(.text+0x20f): In function `init_color_table': c:/grass/grass6/lib/pngdriver/Color_table.c:77: variable 'standard_colors_rgb' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
>> OBJ.i686-pc-mingw32/Color_table.o(.text+0x223):c:/grass/grass6/lib/pngdriver/Color_table.c:77: variable 'standard_colors_rgb' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
>
> According to the Info file, you need to do something like:
>
> void init_color_table(void)
> {
> volatile const struct color_rgb *std_rgb = standard_colors_rgb;
> int colorindex;
>
> if (true_color)
> init_colors_rgb();
> else
> init_colors_indexed();
>
> /* Generate lookup for "standard" colors */
> for (colorindex = 1; colorindex <= MAX_COLOR_NUM; colorindex++)
> LIB_assign_standard_color(
> colorindex,
> DRV_lookup_color(
> (int) std_rgb[colorindex].r,
> (int) std_rgb[colorindex].g,
> (int) std_rgb[colorindex].b)) ;
> }
>
> The alternative is to add a function to libgis, e.g.:
>
> const struct color_rgb *get_standard_color_rgb(int index)
> {
> return &standard_colors_rgb[index];
> }
>
> and use that instead of accessing the array directly.
Yep the first method worked, thanks. lib/display also had two similar
instances that needed changed. Patch included below but I haven't applied
it to CVS as I'm not clear on whether this is a wider problem that's better
worked around with a new library function or not. Also wondering if
there's complications committing to CVS from Windows when the files have
DOS line endings.
Next problem is this one here:
sh-2.04$ cd display/drivers/PNG
sh-2.04$ make
gcc -L/c/grass/grass6/dist.i686-pc-mingw32/lib -Wl,--export-dynamic -L/c/grass/
lib -o /c/grass/grass6/dist.i686-pc-mingw32/driver/PNG -L/c/grass/grass6/dis
t.i686-pc-mingw32/lib OBJ.i686-pc-mingw32/main.o -lgrass_pngdriver -lgrass_drive
r -lgrass_gis -lgrass_datetime -lxdr -liberty -lws2_32 -lz -lgrass_gis
-lgrass_datetime -lxdr -liberty -lws2_32 -lz -lpng -lz -lgrass_drive
r -lgrass_gis -lgrass_datetime -lxdr -liberty -lws2_32 -lz -lgrass_gis
-lgrass_datetime -lxdr -liberty -lws2_32 -lz -lpng -lz -lxdr -l
iberty -lws2_32 -lz
OBJ.i686-pc-mingw32/main.o(.text+0x188): In function `main':
c:/grass/grass6/display/drivers/PNG/main.c:43: undefined reference to `LIB_main'
collect2: ld returned 1 exit status
make: *** [/c/grass/grass6/dist.i686-pc-mingw32/driver/PNG] Error 1
sh-2.04$
LIB_main() should be defined in libgrass_driver, right? Bit lost on this
one. The only other modules with errors are:
GRASS GIS compilation log
-------------------------
Started compilation: Tue Oct 31 09:43:40 WEST 2006
--
Errors in:
/c/grass/grass6/lib/fonts/for_grass
/c/grass/grass6/display/drivers/PNG
/c/grass/grass6/imagery/i.class
/c/grass/grass6/imagery/i.ortho.photo/photo.2image
/c/grass/grass6/imagery/i.ortho.photo/photo.2target
/c/grass/grass6/imagery/i.points
/c/grass/grass6/imagery/i.vpoints
/c/grass/grass6/raster/r.terraflow
So looking fairly good. I was wondering to myself though, to get around
the need to use gis.m for monitor output in the native Windows version,
might it be a more worthwhile use of time to
a) try and resurrect the libw11 native Windows monitor from GRASS 5, or
b) try and get some simple monitor view window working that reads the
output from the PNG driver
I'll think about it.
Paul
Index: display/tran_colr.c
===================================================================
RCS file: /home/grass/grassrepository/grass6/lib/display/tran_colr.c,v
retrieving revision 2.3
diff -u -r2.3 tran_colr.c
--- display/tran_colr.c 18 Apr 2006 05:03:58 -0000 2.3
+++ display/tran_colr.c 31 Oct 2006 08:44:59 -0000
@@ -24,11 +24,12 @@
int D_translate_color(const char *str )
{
+ volatile const struct color_name *std_names = standard_color_names;
int i;
for (i = 0; i < MAX_COLOR_NAMES; i ++) {
- if (! strcmp (str, standard_color_names[i].name))
- return standard_color_names[i].number ;
+ if (! strcmp (str, std_names[i].name))
+ return std_names[i].number ;
}
return(0) ;
@@ -52,6 +53,7 @@
int D_translate_or_add_color (const char * str, int index)
{
+ volatile const struct color_rgb *std_rgb = standard_colors_rgb;
int redi, greeni, bluei;
int i, preallocated, ret;
@@ -78,9 +80,9 @@
the preallocated colors for this color and return the
preallocated index on a match. That is what this does: */
for (i = 1; i <= MAX_COLOR_NUM; i++)
- if (standard_colors_rgb[i].r == redi &&
- standard_colors_rgb[i].g == greeni &&
- standard_colors_rgb[i].b == bluei)
+ if (std_rgb[i].r == redi &&
+ std_rgb[i].g == greeni &&
+ std_rgb[i].b == bluei)
return i ;
/* Add the specified color to the suggested index */
Index: pngdriver/Color_table.c
===================================================================
RCS file: /home/grass/grassrepository/grass6/lib/pngdriver/Color_table.c,v
retrieving revision 1.2
diff -u -r1.2 Color_table.c
--- pngdriver/Color_table.c 19 Sep 2006 10:18:48 -0000 1.2
+++ pngdriver/Color_table.c 31 Oct 2006 08:45:00 -0000
@@ -66,7 +66,9 @@
void init_color_table(void)
{
+ volatile const struct color_rgb *std_rgb = standard_colors_rgb;
int colorindex;
+
if (true_color)
init_colors_rgb();
else
@@ -77,9 +79,9 @@
LIB_assign_standard_color(
colorindex,
DRV_lookup_color(
- (int) standard_colors_rgb[colorindex].r,
- (int) standard_colors_rgb[colorindex].g,
- (int) standard_colors_rgb[colorindex].b)) ;
+ (int) std_rgb[colorindex].r,
+ (int) std_rgb[colorindex].g,
+ (int) std_rgb[colorindex].b)) ;
}
static int get_color_rgb(int r, int g, int b)
More information about the grass-dev
mailing list