rsmpi: Compilation failed, 'stddef.h' file not found

I tried to run the example provided in the README.md file. However, the compilation of the mpi crate failed for me with the following output:

   Compiling mpi v0.1.7
failed to run custom build command for `mpi v0.1.7`
Process didn't exit successfully: `/home/jgreitemann/Documents/Programming/rust/rsmpi-test/target/debug/build/mpi-4dd1b45724a1a7b9/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("x86_64-unknown-linux-gnu")
OPT_LEVEL = Some("0")
PROFILE = Some("debug")
TARGET = Some("x86_64-unknown-linux-gnu")
debug=true opt-level=0
TARGET = Some("x86_64-unknown-linux-gnu")
TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-unknown-linux-gnu = None
CC_x86_64_unknown_linux_gnu = None
HOST_CC = None
CC = Some("mpicc")
TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("x86_64-unknown-linux-gnu")
CFLAGS_x86_64-unknown-linux-gnu = None
CFLAGS_x86_64_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
running: "mpicc" "-O0" "-c" "-ffunction-sections" "-fdata-sections" "-g" "-m64" "-fPIC" "-o" "/home/jgreitemann/Documents/Programming/rust/rsmpi-test/target/debug/build/mpi-4dd1b45724a1a7b9/out/src/rsmpi.o" "src/rsmpi.c"
TARGET = Some("x86_64-unknown-linux-gnu")
TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("x86_64-unknown-linux-gnu")
AR_x86_64-unknown-linux-gnu = None
AR_x86_64_unknown_linux_gnu = None
HOST_AR = None
AR = None
TARGET = Some("x86_64-unknown-linux-gnu")
running: "ar" "crus" "/home/jgreitemann/Documents/Programming/rust/rsmpi-test/target/debug/build/mpi-4dd1b45724a1a7b9/out/librsmpi.a" "/home/jgreitemann/Documents/Programming/rust/rsmpi-test/target/debug/build/mpi-4dd1b45724a1a7b9/out/src/rsmpi.o"
cargo:rustc-link-lib=static=rsmpi
cargo:rustc-link-search=native=/home/jgreitemann/Documents/Programming/rust/rsmpi-test/target/debug/build/mpi-4dd1b45724a1a7b9/out
cargo:rustc-link-search=native=/usr/lib64/openmpi/lib

--- stderr
ar: `u' modifier ignored since `D' is the default (see `U')
warning: argument unused during compilation: '-L/usr/lib64/openmpi/lib' [-Wunused-command-line-argument]
/usr/include/openmpi-x86_64/mpi.h:223:10: fatal error: 'stddef.h' file not found
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: ()', ../src/libcore/result.rs:732

I’m running Fedora 22, Rust 1.3.0, and openmpi 1.8.7-1 from the Fedora repos.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

I had this same problem on Ubuntu 16.04.1 – If I installed libclang, the build failed with the stddef.h missing. Installing clang fixed the problem. If this is a known issue it would be useful to update the dependencies section to refer to clang rather than libclang.

Ran into this problem while trying this on our HPC cluster, even though I installed clang and it works just fine by itself. My guess is that Clang is utilizing GCC’s standard library, but on the HPC cluster the GCC standard library is installed in some weird location, which the frontend clang is able to find, but the libclang isn’t able to.

What I ended up doing was to

(1) Run

echo '#include <stddef.h>' | mpicc -M -E -

to find out where the standard headers are. It should print something like:

-.o: \
  /some/weird/path/include/stddef.h

(2) Before building rsmpi, set the variable via

export C_INCLUDE_PATH=/some/weird/path/include"${C_INCLUDE_PATH+:}${C_INCLUDE_PATH-}"

Edit: Changed command to use mpicc instead of clang.