# Public method in out of tree module

**URL:** <https://www.ruby-forum.com/t/public-method-in-out-of-tree-module/237657>\
**Category:** GNU Radio\
**Created:** [November 22, 2013, 4:53pm UTC](https://www.ruby-forum.com/t/public-method-in-out-of-tree-module/237657 "2013-11-22T16:53:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [November 22, 2013, 4:53pm UTC](https://www.ruby-forum.com/t/public-method-in-out-of-tree-module/237657/1 "2013-11-22T16:53:02Z")

</div>

Hello,

I am trying to create a block that has a publicly accessible method and  
am  
having trouble accessing the method from within Python. Here is a  
simple  
example of my process.

First, I boot Gnuradio Live DVD, Ubutnu 12.04, Gnuradio 3.7.2

Second, i create a new module according to:  
[http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules](http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules)

> gr\_modtool newmod testmod  
> cd gr-testmod  
> gr\_modtool add -t general testblock (empty argument list, default answers)  
> vim lib/testblock\_impl.cc (Edit this to the same as the square\_ff.cc code  
> from the example)  
> mkdir build  
> cd build  
> cmake …/  
> make  
> sudo make install  
> sudo ldconfig

This works fine, I can verify the block is working correctly.

Then I edit the public header file to add a pure virtual method pub()

vim include/testmod/testblock.h

> …  
> public:  
> virtual int pub() = 0;  
> …

Then I edit the private header file to implement the method

> …  
> public:  
> int pub(){ return 1; }  
> …

If I build this, it will make and install just fine. The only problem  
comes when I run python like so

> import testmod  
> b = testmod.testblock()  
> b.pub()

I get the following error:

> AttributeError: ‘testblock\_sptr’ object has no attribute ‘pub’

I’ve tried following the examples of in tree blocks, but just cannot  
seem  
to be able to access pub() from python. Am I missing an include, or  
something?

Thank you,

Dirk

---

<div class="post-metadata">

**Author:** ![Dirk\_Van\_Bruggen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58956e/32.png) [@Dirk\_Van\_Bruggen](https://www.ruby-forum.com/u/Dirk_Van_Bruggen)\
**Post date:** [November 22, 2013, 5:21pm UTC](https://www.ruby-forum.com/t/public-method-in-out-of-tree-module/237657/2 "2013-11-22T17:21:40Z")

</div>

On Fri, Nov 22, 2013 at 10:51:22AM -0500, Dirk Van Bruggen wrote:

> I’ve tried following the examples of in tree blocks, but just cannot seem  
> to be able to access pub() from python. Am I missing an include, or  
> something?

Just to make sure, did you rebuild everything (including SWIG bindings)?  
Are you accessing pub() from QA code? If not, did you reinstall  
afterwards?

MB

–  
Karlsruhe Institute of Technology (KIT)  
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.  
Research Associate

Kaiserstraße 12  
Building 05.01  
76131 Karlsruhe

Phone: +49 721 608-43790  
Fax: +49 721 608-46071  
www.cel.kit.edu

KIT – University of the State of Baden-Württemberg and  
National Laboratory of the Helmholtz Association

---

<div class="post-metadata">

**Author:** ![Dirk\_Van\_Bruggen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58956e/32.png) [@Dirk\_Van\_Bruggen](https://www.ruby-forum.com/u/Dirk_Van_Bruggen)\
**Post date:** [November 22, 2013, 5:25pm UTC](https://www.ruby-forum.com/t/public-method-in-out-of-tree-module/237657/3 "2013-11-22T17:25:11Z")

</div>

On 11/22/2013 07:51 AM, Dirk Van Bruggen wrote:

> I’ve tried following the examples of in tree blocks, but just cannot  
> seem to be able to access pub() from python. Am I missing an include,  
> or something?

There is an bug in the OOT build system where, after having compiled  
once, changes to public header files don’t result in remaking the  
dependent SWIG library. A workaround is to do make clean, then make  
again.
