[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding external libs to an OOT block
From: |
Ryan Volz |
Subject: |
Re: Adding external libs to an OOT block |
Date: |
Tue, 22 Feb 2022 13:06:24 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
Hi Dave,
On 2/22/22 11:34 AM, David Cherkus wrote:
So, I found
https://stackoverflow.com/questions/48562304/gnuradio-c-oot-extrernal-so-library
<https://stackoverflow.com/questions/48562304/gnuradio-c-oot-extrernal-so-library>
which is a very good answer to how to get your OOT block to link to a shared library
from another package.
/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*/
Am wondering if this is documented on the GNUradio web site? I could use a bit more
info, but will give it a go anyway. I did the C++ tutorial (
https://wiki.gnuradio.org/index.php?title=Guided_Tutorial_GNU_Radio_in_C%2B%2B
<https://wiki.gnuradio.org/index.php?title=Guided_Tutorial_GNU_Radio_in_C%2B%2B>
) and this was the very next thing I wanted to do, and I presume many others as
well. I know it's hard to know where to draw the line on teaching enough vs too
much, but I think this is a pretty frequent use case, no? Note that I am teaching
myself cmake on the fly. That's OK, I just taught myself enough C++ to understand
the tutorial on the fly as well.
Regards,
Dave.
This can be easier or harder depending on how well the library you want to link with
supports CMake. In more detail, you may or may not have to do step 2 of the instructions
above, and it may be possible to skip 4 as well if the library's include paths are part
of the target that you "link" with in step 3. So I think it is most helpful to
ask: what library specifically are you needing to link with?
In general I think covering how to use CMake is best left to the CMake documentation, but
the GNU Radio tutorials could probably benefit from a simple example of linking with a
"nice" external library. (That's if they don't already include that somewhere,
and I can't say that I've looked!)
Cheers,
Ryan