diff options
author | Ryan Volz <rvolz@mit.edu> | 2020-07-08 15:02:44 -0400 |
---|---|---|
committer | michael-west <michael.west@ettus.com> | 2020-07-13 13:06:04 -0700 |
commit | 14d9452a15a6e65b01e19e0d5ce0c67afc060cc2 (patch) | |
tree | 6c75af5782a26ab17a8213522484288c61047357 /host/lib/utils | |
parent | 4f2148e7cada5a66ce5eee92ca956cb22b31b98b (diff) | |
download | uhd-14d9452a15a6e65b01e19e0d5ce0c67afc060cc2.tar.gz uhd-14d9452a15a6e65b01e19e0d5ce0c67afc060cc2.tar.bz2 uhd-14d9452a15a6e65b01e19e0d5ce0c67afc060cc2.zip |
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.
Diffstat (limited to 'host/lib/utils')
-rw-r--r-- | host/lib/utils/paths.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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) |