pothosware / SoapyUHD

Soapy SDR plugins for UHD supported SDR devices
https://github.com/pothosware/SoapyUHD/wiki
GNU General Public License v3.0
55 stars 29 forks source link

cmake: Eanble rpath handling #21

Closed velichkov closed 5 years ago

velichkov commented 5 years ago

Copy the cmake defintions from SoapySDR/CMakeLists.txt

guruofquality commented 5 years ago

Sorry, what error is this addressing and on what platform? I need to know if this is something I can address in SoapySDR itself so client modules can get the correct settings -- if possible.

velichkov commented 5 years ago

When installing from source I usually use a non-standard CMAKE_INSTALL_PREFIX like /opt/soapy/ or ~/.local/ in order to have multiple versions installed at the same time - one from apt/yum repository and one from source. One reason I try to avoid installing in /usr/local is the need for root access.

Without setting the RPATH the linker is not able to load the .so libraries. Setting the LD_LIBRARY_PATH is a bit inconvenient and I in my opinion setting RPATH is the better approach.

Here are some commands I used to installed it in ~/.local/

$ cmake -DCMAKE_INSTALL_PREFIX=~/.local/ ..
$ make install
$ which SoapySDRUtil 
~/.local/bin/SoapySDRUtil
$ ldd ~/.local/bin/SoapySDRUtil | grep libSoapySDR
    libSoapySDR.so.0.6 => not found
$ cmake -DCMAKE_INSTALL_PREFIX=~/.local/ -DCMAKE_AUTOSET_INSTALL_RPATH=ON ..
$ make
$ ldd ~/.local/bin/SoapySDRUtil | grep libSoapySDR
    libSoapySDR.so.0.6 => /home/vasko/.local/lib64/libSoapySDR.so.0.6 (0x00007f36dd728000)
$ SoapySDRUtil --info
######################################################
## Soapy SDR -- the SDR abstraction library
######################################################

Lib Version: v0.6.1-g4daa4329
API Version: v0.6.0
ABI Version: v0.6
Install root: /home/vasko/.local
Search path: /home/vasko/.local/lib64/SoapySDR/modules0.6
No modules found!
Loading modules... done
Available factories...null,

$ cd SoapyUHD/build
$ cmake -DCMAKE_INSTALL_PREFIX=~/.local/ -DUHD_ROOT=~/.local/ ..
Install the project...
-- Install configuration: "Release"
-- Installing: /home/vasko/.local/lib64/SoapySDR/modules0.6/libuhdSupport.so
-- Set runtime path of "/home/vasko/.local/lib64/SoapySDR/modules0.6/libuhdSupport.so" to ""
-- Installing: /home/vasko/.local/lib64/uhd/modules/libsoapySupport.so
-- Set runtime path of "/home/vasko/.local/lib64/uhd/modules/libsoapySupport.so" to ""

$ ldd /home/vasko/.local/lib64/SoapySDR/modules0.6/libuhdSupport.so | grep libSoapySDR.so
    libSoapySDR.so.0.6 => not found

$ ldd /home/vasko/.local/lib64/uhd/modules/libsoapySupport.so | grep libSoapySDR.so.
    libSoapySDR.so.0.6 => not found

$ UHD_MODULE_PATH=~/.local/lib64/uhd/modules/ uhd_find_devices 
Error: EnvironmentError: OSError: dlopen failed to load "/home/vasko/.local/lib64/uhd/modules/libsoapySupport.so"
linux; GNU C++ version 8.0.1 20180207 (Red Hat 8.0.1-0.12); Boost_106600; UHD_003.010.003.000-0-unknown

$ cmake -DCMAKE_INSTALL_PREFIX=~/.local/ -DUHD_ROOT=~/.local/ -DCMAKE_AUTOSET_INSTALL_RPATH=ON ..

$ make install
[ 50%] Built target soapySupport
[100%] Built target uhdSupport
Install the project...
-- Install configuration: "Release"
-- Installing: /home/vasko/.local/lib64/SoapySDR/modules0.6/libuhdSupport.so
-- Set runtime path of "/home/vasko/.local/lib64/SoapySDR/modules0.6/libuhdSupport.so" to "/home/vasko/.local/lib64"
-- Installing: /home/vasko/.local/lib64/uhd/modules/libsoapySupport.so
-- Set runtime path of "/home/vasko/.local/lib64/uhd/modules/libsoapySupport.so" to "/home/vasko/.local/lib64"

$ ldd /home/vasko/.local/lib64/SoapySDR/modules0.6/libuhdSupport.so | grep libSoapySDR.so
    libSoapySDR.so.0.6 => /home/vasko/.local/lib64/libSoapySDR.so.0.6 (0x00007f3e9b7a6000)
$ objdump -p /home/vasko/.local/lib64/SoapySDR/modules0.6/libuhdSupport.so | grep RPATH
  RPATH                /home/vasko/.local/lib64

$ UHD_MODULE_PATH=~/.local/lib64/uhd/modules/ uhd_find_devices --args=driver=audio
linux; GNU C++ version 8.0.1 20180207 (Red Hat 8.0.1-0.12); Boost_106600; UHD_003.010.003.000-0-unknown