Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error - sys/param.h file not found #17

Open
hanusek opened this issue Jan 11, 2023 · 0 comments
Open

Error - sys/param.h file not found #17

hanusek opened this issue Jan 11, 2023 · 0 comments

Comments

@hanusek
Copy link

hanusek commented Jan 11, 2023

Hello @zzeroo
I have a problem with compiling your library.
Compiler cannot found:
https://github.com/stephane/libmodbus/blob/9d3b12861e7bd6880dd0cbdcaed94249ba75765f/src/modbus.h#L12

Version:
libmodbus = "1.0.1"

OS: Ubuntu Linux 18.04 (docker container)
arch: arm-linux-gnueabihf

Example: repo

cargo +1.54.0 b --release --target=arm-unknown-linux-gnueabihf

I have file /usr/arm-linux-gnueabihf/include/sys/param.h in container:

root@b793a21b25db:/usr/local/src# find / -name param.h | grep sys/param.h
/usr/include/x86_64-linux-gnu/sys/param.h
/usr/arm-linux-gnueabi/include/sys/param.h
/usr/arm-linux-gnueabihf/include/sys/param.h

Error:

  fatal: not a git repository (or any of the parent directories): .git
  /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus.h:12:10: fatal error: 'sys/param.h' file not found
  /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus.h:12:10: fatal error: 'sys/param.h' file not found, err: true
  thread 'main' panicked at 'could not reate binding: ()', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/libmodbus-sys-1.0.0/build.rs:126:10

Full log:

error: failed to run custom build command for `libmodbus-sys v1.0.0`

Caused by:
  process didn't exit successfully: `/usr/local/src/target/release/build/libmodbus-sys-da6bd4da5e356b54/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBMODBUS_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_arm-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_arm_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_arm-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_arm_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=LIBMODBUS_STATIC
  cargo:rerun-if-env-changed=LIBMODBUS_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_arm-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_arm_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_arm-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_arm_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_arm-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_arm_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  libmodbus/src/modbus.c => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus.c
  libmodbus/src/win32/modbus.rc => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/win32/modbus.rc
  libmodbus/src/win32/modbus.dll.manifest.in => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/win32/modbus.dll.manifest.in
  libmodbus/src/win32/modbus-9.sln => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/win32/modbus-9.sln
  libmodbus/src/win32/modbus.vcproj => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/win32/modbus.vcproj
  libmodbus/src/win32/Make-tests => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/win32/Make-tests
  libmodbus/src/win32/config.h.win32 => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/win32/config.h.win32
  libmodbus/src/win32/README.win32 => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/win32/README.win32
  libmodbus/src/win32/configure.js => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/win32/configure.js
  libmodbus/src/modbus-private.h => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus-private.h
  libmodbus/src/modbus-tcp-private.h => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus-tcp-private.h
  libmodbus/src/modbus-rtu.c => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus-rtu.c
  libmodbus/src/modbus.h => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus.h
  libmodbus/src/modbus-version.h.in => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus-version.h.in
  libmodbus/src/Makefile.am => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/Makefile.am
  libmodbus/src/modbus-tcp.h => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus-tcp.h
  libmodbus/src/modbus-tcp.c => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus-tcp.c
  libmodbus/src/modbus-data.c => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus-data.c
  libmodbus/src/modbus-rtu-private.h => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus-rtu-private.h
  libmodbus/src/modbus-rtu.h => /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus-rtu.h
  TARGET = Some("arm-unknown-linux-gnueabihf")
  OPT_LEVEL = Some("3")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_arm-unknown-linux-gnueabihf
  CC_arm-unknown-linux-gnueabihf = None
  cargo:rerun-if-env-changed=CC_arm_unknown_linux_gnueabihf
  CC_arm_unknown_linux_gnueabihf = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  RUSTC_LINKER = Some("arm-linux-gnueabihf-gcc")
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  cargo:rerun-if-env-changed=CFLAGS_arm-unknown-linux-gnueabihf
  CFLAGS_arm-unknown-linux-gnueabihf = None
  cargo:rerun-if-env-changed=CFLAGS_arm_unknown_linux_gnueabihf
  CFLAGS_arm_unknown_linux_gnueabihf = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = None
  running: "arm-linux-gnueabihf-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=armv6" "-marm" "-mfpu=vfp" "-I" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include" "-I" "libmodbus/src" "-o" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/build/libmodbus/src/modbus-data.o" "-c" "libmodbus/src/modbus-data.c"
  exit status: 0
  running: "arm-linux-gnueabihf-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=armv6" "-marm" "-mfpu=vfp" "-I" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include" "-I" "libmodbus/src" "-o" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/build/libmodbus/src/modbus-rtu.o" "-c" "libmodbus/src/modbus-rtu.c"
  exit status: 0
  running: "arm-linux-gnueabihf-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=armv6" "-marm" "-mfpu=vfp" "-I" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include" "-I" "libmodbus/src" "-o" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/build/libmodbus/src/modbus-tcp.o" "-c" "libmodbus/src/modbus-tcp.c"
  exit status: 0
  running: "arm-linux-gnueabihf-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=armv6" "-marm" "-mfpu=vfp" "-I" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include" "-I" "libmodbus/src" "-o" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/build/libmodbus/src/modbus.o" "-c" "libmodbus/src/modbus.c"
  exit status: 0
  cargo:rerun-if-env-changed=AR_arm-unknown-linux-gnueabihf
  AR_arm-unknown-linux-gnueabihf = None
  cargo:rerun-if-env-changed=AR_arm_unknown_linux_gnueabihf
  AR_arm_unknown_linux_gnueabihf = None
  cargo:rerun-if-env-changed=TARGET_AR
  TARGET_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  running: "arm-linux-gnueabihf-ar" "cq" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/build/libmodbus.a" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/build/libmodbus/src/modbus-data.o" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/build/libmodbus/src/modbus-rtu.o" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/build/libmodbus/src/modbus-tcp.o" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/build/libmodbus/src/modbus.o"
  exit status: 0
  running: "arm-linux-gnueabihf-ar" "s" "/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/build/libmodbus.a"
  exit status: 0
  cargo:rustc-link-lib=static=modbus
  cargo:rustc-link-search=native=/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/build
  cargo:root=/usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out
  YIPPIE bindgen

  --- stderr
  fatal: not a git repository (or any of the parent directories): .git
  /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus.h:12:10: fatal error: 'sys/param.h' file not found
  /usr/local/src/target/arm-unknown-linux-gnueabihf/release/build/libmodbus-sys-4ca48fe86eb6a401/out/include/modbus.h:12:10: fatal error: 'sys/param.h' file not found, err: true
  thread 'main' panicked at 'could not reate binding: ()', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/libmodbus-sys-1.0.0/build.rs:126:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
warning: The libiec61850_sys ARCH is "x86_64"
warning: The libiec61850_sys CARGO_CFG_TARGET_ARCH: arm

Dockerfile:

FROM ubuntu:18.04
ARG DEBIAN_FRONTEND=noninteractive

RUN apt update --fix-missing -y
RUN apt install -y build-essential gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-dev-armhf-cross
RUN apt install -y gcc-multilib-arm-linux-gnueabihf g++-multilib-arm-linux-gnueabihf
RUN apt install -y automake autoconf clang-3.9 libclang-dev libtool
RUN apt install -y sshpass sed curl unzip tar wget git-core git iputils-ping pkg-config sudo libgl1-mesa-dev
RUN apt install -y linux-headers-generic

ENV PKG_CONFIG_ALLOW_CROSS=1

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y

ENV PATH=/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/arm-linux-gnueabihf/bin/

RUN rustup toolchain add 1.54.0-x86_64-unknown-linux-gnu
RUN rustup default 1.54.0-x86_64-unknown-linux-gnu
RUN rustup target add arm-unknown-linux-gnueabihf

RUN mkdir -p /source /.cargo /usr/local/src && \
    echo "[target.arm-unknown-linux-gnueabihf]\nlinker = \"arm-linux-gnueabihf-gcc\"" > /.cargo/config

ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc CC_armv7_unknown_Linux_gnueabihf=arm-linux-gnueabihf-gcc CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/arm-linux-gnueabihf/pkgconfig

WORKDIR /usr/local/src
VOLUME /usr/local/src
VOLUME /transfer

COPY . .
 
CMD cargo +1.54.0 b --release --target=arm-unknown-linux-gnueabihf && cp ./target/arm-unknown-linux-gnueabihf/release/* /transfer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant