Skip to content

Commit d52015f

Browse files
committed
Fix link failure when building on Fedora 64bit
Fedora and other Linux distributions tend to use `lib64` as the library directory and when building and installing the native library with CMake the directory structure in the prefix conforms to this standard. This makes the linking fail since the search directory for `libnng` is set to `lib`. This patch renames `lib64` to `lib` in the install directory. There are no checks performed beforehand since the Rust API already checks that the operation can be performed, and if the rename fails then the directory name is already correct. The same issue is also present for `mbedtls` and was fixed there as well.
1 parent 85961f1 commit d52015f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

build.rs

+11
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ fn build_mbedtls(nng: &mut cmake::Config, is_ninja: bool) {
194194

195195
let mut dest = config.build();
196196

197+
// On some 64bit Linux distributions the library directory is `lib64`
198+
// instead of `lib`. Rename it in the name of consistency.
199+
#[cfg(target_os = "linux")]
200+
let _ = std::fs::rename(dest.as_path().join("lib64"), dest.as_path().join("lib"));
201+
197202
nng.define("MBEDTLS_ROOT_DIR", &dest);
198203

199204
dest.push("lib");
@@ -274,6 +279,12 @@ fn build() {
274279

275280
println!("cargo:rustc-link-lib=static=nng");
276281
let mut dest = config.build();
282+
283+
// On some 64bit Linux distributions the library directory is `lib64`
284+
// instead of `lib`. Rename it in the name of consistency.
285+
#[cfg(target_os = "linux")]
286+
let _ = std::fs::rename(dest.as_path().join("lib64"), dest.as_path().join("lib"));
287+
277288
dest.push("lib");
278289
println!("cargo:rustc-link-search=native={}", dest.display());
279290
}

0 commit comments

Comments
 (0)