0
votes

I know there is a similar post to this but I followed it and I'm still seeing the issue so I thought I'd ask again sorry. I downloaded the bbindgen-tutorial-bzip2-sys and tried to run it but I get the following error

  wrapper.h:1:10: fatal error: 'bzlib.h' file not found
  wrapper.h:1:10: fatal error: 'bzlib.h' file not found, err: true

The other user suggested downgrading the Bindgen version in the .toml and I tried that and I still see the issue, also I verified that bzip2 is installed.

Is there a known clang version that works with Bindgen?

Thanks

-------------------------------------------------------Update------------------------------------------------------------------

So I installed the dev bzip files and verified that the library was in a folder that ld looked at by adding the path to LD_LIBRARY_PATH and then updating with ldconfig. I am now able to compile when I run CARGO BUILD,

fred@fred-MS-7B06:~/rust_projects/bindgen-tutorial-bzip2-sys-master$ cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s

however now when I try to run the program with CARGO TEST, as per the tutorial

https://rust-lang.github.io/rust-bindgen/print.html#include-the-generated-bindings-in-srclibrs

I now get the following error:

  = note: /bin/ld: cannot find -lbz2
          collect2: error: ld returned 1 exit status

I found a post that appeared to have the same issue:

https://dev.to/rrampage/cargo-refused-to-build-my-project---a-rust-debugging-story-25e9

And they fixed it by adding a config.toml file and specified the linker, I tried this and still got the same error. Any ideas as to what I can check I'm a little stuck on this one.

Also I checked the bzip2 dev file that I downloaded from the website:

https://www.sourceware.org/bzip2/

I noticed that there is no file called bz2 but there is a libbz2.def and a libbz2.dsp file, is it possible my ld is incorrectly removing the "lib" from the name?

1
What OS? And you say that bzip2 is installed, but are the bzip2 development files installed? On Ubuntu and similar Linux distros they come in a separate package.Jmb
Hi yes this is on Ubuntu. Ok sorry I didn’t realize the development files are different I can give that a try.fmc5046
On that note do you know what paths bindgen looks at to find shared libraries?fmc5046
It would be easier and less error-prone to apt-get install libbz2-dev rather than attempting to install from sourceware.Jmb
Wow cant believe I couldnt figure that out..... yea that fixed the issue I was having, thanks so much for the help! Sorry I'm new to the whole linker idea, what files is ld looking for in order to link, is it the .so file for a Linux OS, thats what I've gathered from googling?fmc5046

1 Answers

0
votes

As noted by @Jmb in the comments, I needed to install libbz2-dev:

sudo apt install libbz2-dev

Since this was a fairly new WSL instance of Ubuntu, I also needed libclang-dev:

sudo apt install libclang-dev