Re: [RFH] dextractor
On Thu, Feb 18, 2021 at 07:51:34PM +0530, Nilesh Patra wrote:
> /usr/bin/ld: /tmp/ccd5ujJJ.o: warning: relocation against
/usr/bin/ld is the build architecture linker. I would expect the host
one here.
> `H5T_NATIVE_INT_g' in read-only section `.text.startup'
> /usr/bin/ld: /tmp/ccd5ujJJ.o: in function `main':
> dextract.c:(.text.startup+0x1c): undefined reference to `H5Zfilter_avail'
> /usr/bin/ld: dextract.c:(.text.startup+0x4d0): undefined reference to
It's missing symbols from -lhdf5, which presumably is only installed for
the host architecture.
> --- /dev/null
> +++ b/debian/patches/cross.patch
> @@ -0,0 +1,16 @@
> +--- a/Makefile
> ++++ b/Makefile
> +@@ -1,3 +1,4 @@
> ++PKG_CONFIG ?= pkg-config
> + CFLAGS = -O3 -Wall -Wextra -fno-strict-aliasing
> + MACHINE_ARCH := $(shell echo `uname -m`)
> +
> +@@ -5,7 +6,7 @@
> +
> + dextract: dextract.c DB.c DB.h QV.c QV.h
> + #gcc $(CFLAGS) -I/usr/include/hdf5/serial/ -L/usr/lib/${MACHINE_ARCH}-linux-gnu/hdf5/serial/ -o dextract dextract.c DB.c QV.c -lhdf5
> +- gcc $(CFLAGS) $(ARGS) -o dextract dextract.c DB.c QV.c -lhdf5
> ++ gcc $(ARGS) $(CFLAGS) -o dextract dextract.c DB.c QV.c `$(PKG_CONFIG) --libs hdf5`
I think the -lhdf5 is not the issue here. Using pkg-config to discover
the library likely is more porttable, but it shouldn't change the
picture here. I'd expect it to exhibit the same error as an unmodified
build. A quick peek inidicates that the failure mode is different (it
skips an incompatible -lhdf5 and gives up). It is unclear to me why it
actually proceeds linking here.
Anyway, the real issue is the gcc invocation. It's the build
architecture compiler. Please use $(CC) here. It'll be supplied by
dh_auto_build. You don't have to assign CC anywhere as make defaults it
to "cc".
> --- a/debian/rules
> +++ b/debian/rules
> @@ -12,7 +12,7 @@ include /usr/share/dpkg/default.mk
>
> override_dh_auto_build:
> ifneq ($(wildcard /usr/lib/$(DEB_HOST_MULTIARCH)/hdf5/serial/libhdf5.so),)
> - $(MAKE) all ARGS="-I/usr/include/hdf5/serial -L/usr/lib/$(DEB_HOST_MULTIARCH)/hdf5/serial"
> + dh_auto_build -- ARGS="-I/usr/include/hdf5/serial"
Replacing this -L flag with a pkg-config invocation is irrelevant to
cross building, but still an improvement in portability.
Helmut
Reply to: