[GRASS-dev] G7: landsat_met.c:103: undefined reference to `chrncpy'

Hamish hamish_b at yahoo.com
Mon Jul 29 04:16:28 PDT 2013


Hi,

I think it needs additional LDFLAGS too.

here's an example from the debian/unstable build

include /usr/share/hardening-includes/hardening.make
CFLAGS=$(shell dpkg-buildflags --get CFLAGS)
LDFLAGS=$(shell dpkg-buildflags --get LDFLAGS)

# ->
CFLAGS="-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security"
LDFLAGS="-Wl,-z,relro"

# then
CFLAGS+=$(HARDENING_CFLAGS)
LDFLAGS+=$(HARDENING_LDFLAGS)

(I'll echo those out in the morning if you need them)

# TODO: fix these
CFLAGS+=-Wno-error=format-security

...

gcc -I/home/hamish/src/grass/grass-6.4.3/dist.x86_64-pc-linux-gnu/include \
 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat \
 -Werror=format-security -fPIE  -fstack-protector --param ssp-buffer-size=4 \
 -D_FORTIFY_SOURCE=2  -Wformat -Wformat-security -Werror=format-security \
 -Wall -O    -fPIC   -DPACKAGE=\""grasslibs"\" -D_FILE_OFFSET_BITS=64 \
 -DGDAL_LINK=1 -DGDAL_DYNAMIC=1   -DPACKAGE=\""grasslibs"\" \
 -I/usr/include/gdal -I/usr/include/gdal \
 -I/home/hamish/src/grass/grass-6.4.3/dist.x86_64-pc-linux-gnu/include \
 -o OBJ.x86_64-pc-linux-gnu/adj_cellhd.o -c adj_cellhd.c



Hamish




----- Original Message -----
> From: Markus Neteler <neteler at osgeo.org>
> To: GRASS developers list <grass-dev at lists.osgeo.org>
> Cc: 
> Sent: Monday, July 29, 2013 10:29 PM
> Subject: [GRASS-dev] G7: landsat_met.c:103: undefined reference to `chrncpy'
> 
> Hi,
> 
> I changed my compiler flags to catch more potential errrors and got this one:
> 
> [neteler at north i.landsat.toar]$ make
> gcc  -g -Wall -fno-common -fexceptions -std=gnu99
> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector -m64
> -mtune=generic
> -I/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/include
> -I/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/include
> -DPACKAGE=\""grassmods"\"
> -I/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/include
> -I/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/include -o
> OBJ.x86_64-unknown-linux-gnu/landsat_met.o -c landsat_met.c
> In file included from /usr/include/stdio.h:27:0,
>                  from landsat_met.c:1:
> /usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE
> requires compiling with optimization (-O) [-Wcpp]
> : && gcc -L/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
> -L/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
> -Wl,--export-dynamic  -L/usr/lib64
> -Wl,-rpath-link,/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
> -o /home/neteler/grass70/dist.x86_64-unknown-linux-gnu/bin/i.landsat.toar
> OBJ.x86_64-unknown-linux-gnu/landsat_set.o
> OBJ.x86_64-unknown-linux-gnu/main.o
> OBJ.x86_64-unknown-linux-gnu/landsat.o
> OBJ.x86_64-unknown-linux-gnu/earth_sun.o
> OBJ.x86_64-unknown-linux-gnu/landsat_met.o    -lgrass_raster.7.0.svn
> -lgrass_gis.7.0.svn  -lm
> OBJ.x86_64-unknown-linux-gnu/landsat_met.o: In function `lsat_metadata':
> /home/neteler/grass70/imagery/i.landsat.toar/landsat_met.c:103:
> undefined reference to `chrncpy'
> /home/neteler/grass70/imagery/i.landsat.toar/landsat_met.c:112:
> undefined reference to `chrncpy'
> /home/neteler/grass70/imagery/i.landsat.toar/landsat_met.c:122:
> undefined reference to `chrncpy'
> collect2: error: ld returned 1 exit status
> make: *** 
> [/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/bin/i.landsat.toar]
> Error 1
> 
> Does anyone know how to fix that? Perhaps related to the use of
> -D_FORTIFY_SOURCE=2
> 
> Markus
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
> 


More information about the grass-dev mailing list