Error when build c/c++ dependencies: can't found #246
-
I'm a C/C++ novice, I have a rust project that has C/C++ dependencies, X11/Xatom.h This library can be found during normal cargo build —target x86_64-unknown-linux-gnu compilation, when using zigbuild, the X11/Xatom.h` cannot be found when specifying any version of glibc on the same platform. Thanks for any help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Assuming that This should work for you ( CFLAGS='-isystem /usr/include' RUSTFLAGS='-L /usr/lib64' cargo zigbuild --release --target x86_64-unknown-linux-gnuZig should provide it's own headers and those should be preferred when building for older glibc. You would not want to use Full explanationThe default system libs like Lines 839 to 841 in eba2d7e To include that again you can use args like # `cargo-zigbuild` effectively runs `zig cc -nostdinc`,
# which excludes system include dir `/usr/include`, add it back via `-isystem`:
CC='zig cc -nostdinc -isystem /usr/include' make installWhen you use These two extra flags need to be picked up separately usually if you've got a common command like
Hence here's how CC='zig cc -target x86_64-linux-gnu' CFLAGS='-isystem /usr/include' LDFLAGS='-L /usr/lib64' make install
CFLAGS='-isystem /usr/include' RUSTFLAGS='-L /usr/lib64' cargo zigbuild --release --target x86_64-unknown-linux-gnu |
Beta Was this translation helpful? Give feedback.
Assuming that
X11/Xatom.his found at/usr/include, this should be fixable by including the system directory (whichzigexcludes when-nostdinc/-targetis configured whichcargo zigbuildsets).This should work for you (
RUSTFLAGSmay not be necessary sometimes):Zig should provide it's own headers and those should be preferred when building for older glibc. You would not want to use
-I /usr/includewhich would introduce conflicts. This should provide fallback to/usr/includefor additional header files from other system packages.Full explanation
The default system libs like