Hi Dave,
fortunately, the process got simpler.
For now, let's assume the library you want to use supports CMake. In my
experience, every library you can install via `sudo apt install
lib...-dev` supports CMake.
Let's assume you want to use libfmt, then you need:
`find_package(fmt REQUIRED)`
in your top-level CMakeLists.txt.
In your `/lib/CMakeLists.txt` you need to add:
`target_link_libraries({YOUROOTMODULENAME} gnuradio::gnuradio-runtime
fmt::fmt)`.
That's it.
In case of VOLK, the 2 entries are:
`find_package(Volk REQUIRED)`
and
`Volk::volk`
The `REQUIRED` option let's CMake fail if it can't find the necessary
information. Otherwise, you'd have to check everything yourself.
You might have noticed that you can e.g. use VOLK without the CMake
entries in your OOT. That's because you include it with the GNU Radio
CMake config.
Cheers
Johannes
On 22.02.22 19:06, Ryan Volz wrote:
> 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
>
No comments:
Post a Comment