discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems using multiple C files in OOT Block


From: George Edwards
Subject: Problems using multiple C files in OOT Block
Date: Tue, 19 Oct 2021 08:55:48 -0500

Hello GNURadio Community, 

With complex algorithms, there are times when one needs to add C files to an OOT module on top of those created by the gr_modtool to make the coding more modular and cleaner. I made a try with a trivial C++ adder function file, but could not get it to work. Below is a description of what I did:

I created an OOT C++ module name tutorial and added the block my_adder_ff with inputs float a and float b.

gr_modtool creates the files my_adder_ff_imp.cc and my_adder_ff_imp.h 

In the module lib directory, I created an additional C++ file named my_add_function.cc containing the definition for the function my_add(float a, float b). Inside this file I included the header:
#include "my_adder_ff_imp.h"
And, wrapped the function definition in the namespaces:
namespace gr {
    namespace tutorial{
           float my_add(float a, float b){
                   float c;
                   c = a+b:
                    return c
           }
    }
}

I further did the following:
1. Inside my_adder_ff_imp.h , I declared  float my_add(float a, float b)  
 2. I called the adder,  val = my_add(a, b) inside my_adder_ff_imp.cc
 3. In the CMakeLists.txt in the lib directory, I included the source file my_add_function.cc under my_adder_ff_imp.cc (already included by the gr_modtool)
When I compiled and run, it failed because it could not see the function my_add.

Will appreciate any help in leading me towards resolving this issue.

Regards,
George 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]