Skip to content

Commit bc501ed

Browse files
authored
Fix link failure when building on Fedora 64bit (#1)
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 adds `lib64` to the library search path on Linux. The same issue is also present for `mbedtls` and was fixed there as well.
1 parent 85961f1 commit bc501ed

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

build.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,17 @@ fn build_mbedtls(nng: &mut cmake::Config, is_ninja: bool) {
192192
config.define("ENABLE_PROGRAMS", "OFF");
193193
config.define("ENABLE_TESTING", "OFF");
194194

195-
let mut dest = config.build();
195+
let dest = config.build();
196196

197197
nng.define("MBEDTLS_ROOT_DIR", &dest);
198198

199-
dest.push("lib");
200199
println!("cargo:rustc-link-lib=static=mbedcrypto");
201200
println!("cargo:rustc-link-lib=static=mbedtls");
202201
println!("cargo:rustc-link-lib=static=mbedx509");
203-
println!("cargo:rustc-link-search=native={}", dest.display());
202+
println!("cargo:rustc-link-search=native={}", dest.as_path().join("lib").display());
203+
// On some 64bit Linux distributions the library directory is `lib64` instead of `lib`
204+
#[cfg(target_os = "linux")]
205+
println!("cargo:rustc-link-search=native={}", dest.as_path().join("lib64").display());
204206
}
205207

206208
fn build() {
@@ -273,9 +275,12 @@ fn build() {
273275
}
274276

275277
println!("cargo:rustc-link-lib=static=nng");
276-
let mut dest = config.build();
277-
dest.push("lib");
278-
println!("cargo:rustc-link-search=native={}", dest.display());
278+
let dest = config.build();
279+
280+
println!("cargo:rustc-link-search=native={}", dest.as_path().join("lib").display());
281+
// On some 64bit Linux distributions the library directory is `lib64` instead of `lib`
282+
#[cfg(target_os = "linux")]
283+
println!("cargo:rustc-link-search=native={}", dest.as_path().join("lib64").display());
279284
}
280285

281286
fn main() {

0 commit comments

Comments
 (0)