Cross-compilation of libzwaveip for Raspberry Pi from Ubuntu fails during make step


#1

First of all, I love the libzwaveip reference client repository. Simple instructions compiles easily on the Raspberry Pi, but I intend to cross-compile from my Ubuntu workstation (or more accurately, an Ubuntu Docker container.)

Using Z/IP Gateway RPi.cmake and cross-compilation instructions from ZTS as inspiration, I can run cmake, but then receive a compilation error when running make: “/usr/include/libxml2/libxml/encoding.h:31:26: fatal error: unicode/ucnv.h: No such file or directory”

Following the build instructions from libzwaveip, I’m running this in my dockerfile (based on ubuntu:latest)

apt-get install cmake libssl-dev libavahi-client-dev libxml2-dev libbsd-dev libncurses5-dev git

Afterwards, when trying to do my cmake and make, I’m receiving the failing terminal output below. Note that cross-compiled output of libusb and openssl for Raspberry Pi is already present.

root@a871fc0bb207:/var/libzwaveip# echo $LIBUSBDIR
/var/tools/libusb-1.0.19
root@a871fc0bb207:/var/libzwaveip# echo $OPENSSLDIR
/var/tools/openssl-1.0.1j
root@a871fc0bb207:/var/libzwaveip# mkdir build_rpi
root@a871fc0bb207:/var/libzwaveip# cd build_rpi/
root@a871fc0bb207:/var/libzwaveip/build_rpi# cmake -DOPENSSL_ROOT_DIR=$OPENSSLDIR -DOPENSSL_LIBRARIES=$OPENSSLDIR -DOPENSSL_SRC=$OPENSSLDIR -DLIBUSB_SRC=$LIBUSBDIR -DCMAKE_TOOLCHAIN_FILE=../cmake/Rpi.cmake -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc ..
-- openssl_include: /var/tools/openssl-1.0.1j/include/
-- libusb_include: /var/tools/libusb-1.0.19/libusb/
-- libpcap_include:
-- openssl_include: /var/tools/openssl-1.0.1j/include/
-- libusb_include: /var/tools/libusb-1.0.19/libusb/
-- libpcap_include:
-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: /var/tools/raspberrypi-tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /var/tools/raspberrypi-tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /var/tools/raspberrypi-tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-c++
-- Check for working CXX compiler: /var/tools/raspberrypi-tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenSSL: /var/tools/openssl-1.0.1j/libssl.so;/var/tools/openssl-1.0.1j/libcrypto.so (found version "1.0.1j")
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.3")
-- Found PythonInterp: /usr/bin/python (found version "2.7.12")
-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE)
---- make doc will not work until doxygen is installed
-- Configuring done
-- Generating done
-- Build files have been written to: /var/libzwaveip/build_rpi
root@a871fc0bb207:/var/libzwaveip/build_rpi# make
Scanning dependencies of target zwaveip
[  1%] Building C object libzwaveip/CMakeFiles/zwaveip.dir/libzwaveip.c.o
[  2%] Building C object libzwaveip/CMakeFiles/zwaveip.dir/zconnection.c.o
[  3%] Building C object libzwaveip/CMakeFiles/zwaveip.dir/network_management.c.o
[  5%] Building C object libzwaveip/CMakeFiles/zwaveip.dir/zresource.c.o
[  6%] Linking C static library libzwaveip.a
[  6%] Built target zwaveip
[  7%] Generating zw_gen_hdr.c
Scanning dependencies of target zw_cmd_tool
[  8%] Building C object xml/CMakeFiles/zw_cmd_tool.dir/zw_cmd_tool.c.o
[ 10%] Building C object xml/CMakeFiles/zw_cmd_tool.dir/zw_gen_hdr.c.o
[ 11%] Linking C static library libzw_cmd_tool.a
[ 11%] Built target zw_cmd_tool
Scanning dependencies of target parse_xml
[ 12%] Building C object xml/CMakeFiles/parse_xml.dir/parse_xml.c.o
In file included from /usr/include/libxml2/libxml/parser.h:810:0,
                 from /var/libzwaveip/xml/parse_xml.c:18:
/usr/include/libxml2/libxml/encoding.h:31:26: fatal error: unicode/ucnv.h: No such file or directory
 #include <unicode/ucnv.h>
                          ^
compilation terminated.
xml/CMakeFiles/parse_xml.dir/build.make:62: recipe for target 'xml/CMakeFiles/parse_xml.dir/parse_xml.c.o' failed
make[2]: *** [xml/CMakeFiles/parse_xml.dir/parse_xml.c.o] Error 1
CMakeFiles/Makefile2:213: recipe for target 'xml/CMakeFiles/parse_xml.dir/all' failed
make[1]: *** [xml/CMakeFiles/parse_xml.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
root@a871fc0bb207:/var/libzwaveip/build_rpi#

Link to libzwaveip:


#2

The libxml2 that your cross-compile environment seems to be using has apparently been built with ICU support. It also looks like your cross-compile environment is missing headers for libicu. On Debian, the package libicu-dev contains what’s needed. Adding libicu to your cross-compile environment should allow the compilation process to continue.


#3

I haven’t tried it myself, but there’s a pull request on the libzwaveip Github for a branch that seems to add some support for cross-compiling. Maybe it’s worth giving it a shot:


#4

Thanks for your prompt response.

That pull request looking very promising, at least explaining the process to configure the cross-compiling toolchain. I’m using the Raspberry Pi toolchain (I’m not familiar with linaro) and will investigate this further.

In my current progress, I’ve been able to install libicu-dev and successfully build libxml2, though I still get the same unicode/ucnv.h error, so I’m not sure if it’s a bad include path. I’ll try out this PR and respond with an update later today.

Tyler


#5

Hi Hans,

The pull request you linked earlier worked as provided. Thank you!

Tyler