informationsea / xlsxwriter-rs

Excel file writer for Rust
https://crates.io/crates/xlsxwriter
Apache License 2.0
265 stars 44 forks source link

Can't Find stdio.h When Compiling Library #14

Open nikhilanayak opened 3 years ago

nikhilanayak commented 3 years ago

Hi. I'm new to Rust, so please forgive me if this is a simple error. I'm trying to compile the package but I'm getting this error:

cargo:warning=third_party/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h:
24:10: fatal error: 'stdio.h' file not found
cargo:warning=#include <stdio.h>

I got this error on both Windows (clang with CygWin) and Linux (clang). How can I solve this?

Edit: This also happens on Windows with LLVM/clang. Testing clang with a simple c program that uses stdio.h also works. I suspect this has something to do with Rust not using the include path but I have no idea how to solve it.

goodidea-kp commented 3 years ago

The same error, I guess...

exit status: 0

13 94.71 running: "ar" "s" "/usr/src/my-app/target/release/build/libxlsxwriter-sys-9a963e892e16cf5e/out/libxlsxwriter.a"

13 94.71 exit status: 0

13 94.71 cargo:rustc-link-lib=static=xlsxwriter

13 94.71 cargo:rustc-link-search=native=/usr/src/my-app/target/release/build/libxlsxwriter-sys-9a963e892e16cf5e/out

13 94.71

13 94.71 --- stderr

13 94.71 /usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found

13 94.71 /usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found, err: true

13 94.71 thread 'main' panicked at 'Unable to generate bindings: ()', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/libxlsxwriter-sys-1.1.1/build.rs:117:10

13 94.71 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

13 94.71 warning: build failed, waiting for other jobs to finish...

mamcx commented 2 years ago

Same, trying to use https://github.com/messense/cargo-xwinbuild too.

I tried to set all env vars:

LLVM_PATH="/opt/homebrew/opt/llvm" 
LLVM_VERSION="13.0.1"
export PATH="$LLVM_PATH:$PATH"
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
export LD_LIBRARY_PATH="$LLVM_PATH/lib/:$LD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="$LLVM_PATH/lib/:$DYLD_LIBRARY_PATH"
export CPATH="$LLVM_PATH/lib/clang/$LLVM_VERSION/include/"
export LDFLAGS="-L$LLVM_PATH/lib"
export CPPFLAGS="-I$LLVM_PATH/include"
export CC="$LLVM_PATH/bin/clang"
export CXX="$LLVM_PATH/bin/clang++"

P.D: How about provide precompiled option, like is with sqlite?

tequilaNiu commented 1 year ago

The same error on macOS 13.0.1。I set include like this: sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/ then, the error like this: cargo:warning=/usr/local/include/sys/cdefs.h:913:2: error: Unsupported architecture cargo:warning=/usr/local/include/machine/_types.h:36:2: error: architecture not supported cargo:warning=/usr/local/include/sys/_types.h:55:9: error: unknown type name '__int64_t'; did you mean '__int128_t'?