Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The build script adds standard path to rustc-link-search, causing troubles #31

Open
jerry73204 opened this issue May 14, 2020 · 1 comment

Comments

@jerry73204
Copy link

The section in build.rs can possibly add the standard path /usr/lib (or /usr/lib/x86_64-linux-gnu on Debian) to the rustc-link-search path. It will introduce an extra -L/usr/lib flag to the linker. It is not desired because it overrides the search order of other more specific search paths.

I encountered a scenario to import both opencv and diesel in my project. I install the OpenCV 4 in non-standard path (It's because Ubuntu ships the older OpenCV), and set PKG_CONFIG_PATH to let the build.rs in opencv crate to append the non-standard search paths for me.

In the mean time, the pq-sys required by diesel puts the standard search path to the linker as I pointed here. It causes the linker to search for libopencv_*.so in both standard and non-standard paths, and the build fails due to conflict.

I see an obvious solution is the pkg-config feature. However, pq-sys is not the direct dependency of my project but for the dependent diesel, making the patch a bit difficult. The build script itself should also avoid producing standard paths to the linker.

@jerry73204 jerry73204 changed the title The build script add standard path to rustc-link-search, causing troubles The build script adds standard path to rustc-link-search, causing troubles May 14, 2020
@davepacheco
Copy link

In case this is helpful, I stumbled across what appears to be a workaround for the same issue in libz-sys:
https://github.com/rust-lang/libz-sys/blob/6b12e9a37bae1a444aaa1a11248c5b0e555869b4/build.rs#L37-L43
(which seems relevant because libz-sys is the example that the Cargo docs use for exposing a native library)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants