From 14d9452a15a6e65b01e19e0d5ce0c67afc060cc2 Mon Sep 17 00:00:00 2001 From: Ryan Volz Date: Wed, 8 Jul 2020 15:02:44 -0400 Subject: utils: Fix prefix determination in get_lib_path() get_lib_path() uses the libuhd location on disk to dynamically determine the installation prefix at runtime. This fix normalizes the libuhd path before any path operations are done to extract the library directory and then prefix directory. Previously, using a non-normalized library path, the returned prefix directory would be incorrect in some cases (e.g. when loaded through GNU Radio). In these error cases, the libuhd path would be $PREFIX/lib/./libuhd.so (with a no-op /. inserted) which would result in a technically correct library directory of `$PREFIX/lib/.` but an incorrect prefix directory of `$PREFIX/lib`. With the normalization fix, the libuhd path is corrected to $PREFIX/lib/libuhd.so and the subsequent path manipulation to get the library and prefix directories will work as intended. --- host/lib/utils/paths.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'host/lib/utils') diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 54b8e0323..e6ed1c177 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -293,7 +293,9 @@ std::string uhd::get_pkg_path(void) std::string uhd::get_lib_path(void) { fs::path runtime_libfile_path = boost::dll::this_line_location(); - return runtime_libfile_path.remove_filename().string(); + //Normalize before decomposing path so result is reliable + fs::path lib_path = runtime_libfile_path.lexically_normal().parent_path(); + return lib_path.string(); } #else std::string uhd::get_pkg_path(void) -- cgit v1.2.3