ibmdb / rust-ibm_db

RUST Driver for IBM Db2 servers
MIT License
18 stars 5 forks source link

[Question] How to address "/usr/bin/ld: cannot find -lodbc"? #3

Closed data-henrik closed 3 years ago

data-henrik commented 3 years ago

I have the Db2 driver installed, cloned this git repo and ran the commands to build the example connect or the package. Both return the error message

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

error: aborting due to previous error

error: could not compile ibm_db

How can I address that error? I searched for libodbc.so / libodbc.a but could not find it. This is on RHEL 8.3

AWADHAMBIKA commented 3 years ago

Hi, @data-henrik not sure why the package is looking for odbc. Can you try installing using crates.io. Also make sure that LD_LIBRARY_PATH is set i.e. export LD_LIBRARY_PATH="/foo/bar/clidriver:/foo/bar/clidriver/include:/foo/bar/clidriver/bin:/foo/bar/clidriver/lib"

Let me know if above works.

data-henrik commented 3 years ago

cargo run --package ibm_db --example setup

That's the failing command.

AWADHAMBIKA commented 3 years ago

Hi @data-henrik I reinstalled the package on RHEL 8 and it installed successfully. I copied the src, example, cargo.toml and build.rs files on the machine and made sure that LD_LIBRARY_PATH is set to point to the correct directory of CLIDriver i.e. db2 driver in the format mentioned in prev message. Then I ran the command "cargo run --package ibm_db --example setup" and it ran seamlessly without error.

Can you please troubleshoot a bit more and check if some other settings are not missing like gcc etc. Some other dependent package might have some dependency that is not getting satisfied possibly. ibm-db package has dependency only on db2 library. Make sure you have the CLI driver installed. If not simply run the setup.rs file to download the same for your environment.

mdgozza commented 3 years ago

@data-henrik ,

I wanted to let you know that I also have issues with the environment variables not being used as lookup directories for the linker. I'm not sure why.

I resolved my issue by using this command:

RUSTFLAGS='-L /db2-query/clidriver/lib' cargo build --release

replace with your correct driver's lib path.

Hope it helps! 👍

EDIT: Also I just noticed in your specific case you were failing to find lodbc. depending on your OS I would sudo apt-get install unixodbc unixodbc-dev or on mac brew install unixodbc