m3x1m0m
m3x1m0m

Reputation: 115

GNURadio C++ OOT Extrernal (.so) Library

I try to compile an OOT module for GNURadio, which uses an external device driver (LimeSuite.h) as a dynamically linked shared object (.so file). After adding

find_package(LimeSuite)

and the corresponding module under cmake/Modules (cf. https://github.com/kit-cel/gr-dab/blob/working_branch/cmake/Modules/FindFaad.cmake), I was able to compile with make and I observed, that the following variables changed.

CMAKE_CXX_FLAGS=-lLimeSuite
LIMESUITE_FOUND=1
LIMESUITE_FOUND=1
LIMESUITE_INCLUDE_DIR=/usr/include
LIMESUITE_INCLUDE_DIRS=/usr/include
LIMESUITE_LIBRARIES=/usr/lib/x86_64-linux-gnu/libLimeSuite.so
LIMESUITE_LIBRARY=/usr/lib/x86_64-linux-gnu/libLimeSuite.so

However as soon as I use the library in my code I get the following error when I try to instantiate the python object.

AttributeError: 'module' object has no attribute 'limesdr_source'

As soon as I remove the C++ code using the library from the implementation part of the block, the instantiation works again. I do not receive any error reports executing make. How can this be? Any idea how to debug this further?

EDIT:

As pointed out by the answer of Marcus Müller below I did not link properly. In fact one has to edit three different cmake files in three places to add an external dynamically loaded library (.so) to an OOT module in GNURadio. I try to explain briefly what to do:

  1. Put a find_package(LIBNAME) in the CMakeLists.txt in the base directory of the OOT module.
  2. Corresponding to that a FindLIBNAME.cmake file in the cmake module path is necessary. This file has the purpose to implement the search for include directories and library files (.so files).
  3. Once found the path to the library has to be used with target_link_libraries(...) in lib/CMakeLists.txt (linking).
  4. The include file path, i.e. LIBNAME.h has to be added as include directory using include_directories(...) in the CMakeLists.txt in the base directory of the module.

With ldd it is possible to find out if the external library is linked correctly.

ldd /usr/local/lib/YOURLIB.so

Upvotes: 4

Views: 1586

Answers (1)

Marcus Müller
Marcus Müller

Reputation: 36442

You probably forgot to add the limesuite object files to the actually linked libraries in lib/CMakeLists.txt.

Anyway, I see zero good reasons why you should link against limesuite in an OOT that is concerned with DAB+ and pretty much hardware agnostic. Instead, encapsulate your lime interfacing in a block in your own OOT! GNU Radio is designed to be a block-connecting framework, so that you don't have to link your signal processing block code against your hardware interfacing driver.

Generating your own OOT should be very easy, indeed: https://tutorials.gnuradio.org

Upvotes: 4

Related Questions