# Using Out-of-Tree module from C++ Application

**URL:** <https://www.ruby-forum.com/t/using-out-of-tree-module-from-c-application/228941>\
**Category:** GNU Radio\
**Created:** [May 13, 2013, 9:01pm UTC](https://www.ruby-forum.com/t/using-out-of-tree-module-from-c-application/228941 "2013-05-13T21:01:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Buettner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@Michael\_Buettner](https://www.ruby-forum.com/u/Michael_Buettner)\
**Post date:** [May 13, 2013, 9:01pm UTC](https://www.ruby-forum.com/t/using-out-of-tree-module-from-c-application/228941/1 "2013-05-13T21:01:23Z")

</div>

I am trying to use an out of tree module (built according to the  
“Out-of-tree modules” documentation) from a C++ application. The  
module is named “reader”, and the block I’m trying to use is  
“command\_gate\_cc”.

I can use it from python with:  
from reader import reader\_swig  
…  
cg\_block = reader\_swig.command\_gate\_cc\_make()

I can’t figure out how to create a command\_gate\_cc block in C++ though.

/usr/local/lib/libgnuradio-reader.so exists, and ‘nm -CD  
/usr/local/lib/libgnuradio-reader.so’ gives me  
‘0000000000004850 T gr::reader::command\_gate\_cc::make()’

/usr/include/reader\_command\_gate\_cc.h exists:

namespace gr {  
namespace reader {

```
class READER_API command_gate_cc : virtual public gr_block
{
 public:
  typedef boost::shared_ptr<command_gate_cc> sptr;
  static sptr make();
};

```

} // namespace reader  
} // namespace gr

My CC applications has:  
#include \<command\_gate\_cc.h\>  
…  
boost::shared\_ptrgr::reader::command\_gate\_cc cg =  
gr::reader::command\_gate\_cc::make();

But I get the linker error:  
undefined reference to `gr::reader::command\_gate\_cc::make()’

What am I missing? I don’t understand the build system well enough to  
figure out where if that is where I’m going wrong. Any help would be  
appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![Michael\_Buettner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@Michael\_Buettner](https://www.ruby-forum.com/u/Michael_Buettner)\
**Post date:** [May 14, 2013, 7:05pm UTC](https://www.ruby-forum.com/t/using-out-of-tree-module-from-c-application/228941/2 "2013-05-14T19:05:03Z")

</div>

On Mon, May 13, 2013 at 8:00 PM, Michael Buettner  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I can’t figure out how to create a command\_gate\_cc block in C++ though.  
> class READER\_API command\_gate\_cc : virtual public gr\_block  
> #include \<command\_gate\_cc.h\>  
> …  
> boost::shared\_ptrgr::reader::command\_gate\_cc cg =  
> gr::reader::command\_gate\_cc::make();

I think you’re pretty close.

First, you can use the sptr from the class itself:  
gr::reader::command\_gate\_cc::sptr = gr::reader::command\_gate\_cc::make();

> But I get the linker error:  
> undefined reference to `gr::reader::command\_gate\_cc::make()’
> 
> What am I missing? I don’t understand the build system well enough to  
> figure out where if that is where I’m going wrong. Any help would be  
> appreciated. Thanks!

Looks like you aren’t linking properly to your libgnuradio-reader.so.  
Take a look at gr-audio/examples/c++/CMakeLists.txt for how you can  
set up a cmake file properly.

Tom

---

<div class="post-metadata">

**Author:** ![Michael\_Buettner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@Michael\_Buettner](https://www.ruby-forum.com/u/Michael_Buettner)\
**Post date:** [May 17, 2013, 6:49pm UTC](https://www.ruby-forum.com/t/using-out-of-tree-module-from-c-application/228941/3 "2013-05-17T18:49:10Z")

</div>

On Tue, May 14, 2013 at 10:03 AM, Tom R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > cg\_block = reader\_swig.command\_gate\_cc\_make()  
> > namespace reader {
> 
> Tom

Thanks for the pointer, Tom.  
I needed to add ‘gnuradio-reader’ to the library to  
target\_link\_libraries(…).

---

<div class="post-metadata">

**Author:** ![Michael\_Buettner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@Michael\_Buettner](https://www.ruby-forum.com/u/Michael_Buettner)\
**Post date:** [May 30, 2015, 10:06am UTC](https://www.ruby-forum.com/t/using-out-of-tree-module-from-c-application/228941/4 "2015-05-30T10:06:31Z")

</div>

Hello everyone, it has been few days I’m on GNU and is totally new for  
me. I’m very much familiar with c++ and I’ve created few blocks also  
so, if you can help me on the  
programming architect, variable declaration and assigning them  
values,function declaration and making a multiple input & output blocks.
