Hierarchical Block in c++ not working, linker or swig problem

Hi list.

I am trying to write a hierarchical block in c++ in an OOT module.
I create the block with the gr_modtool and try to make a very simple
hier block. The only relevant changes to the template are:

in the …impl.cc:

#include <gnuradio/blocks/copy.h>

testhier::make()… unchanged

gr::blocks::copy::sptr copy(gr::blocks::copy::make(sizeof(gr_complex)));
connect(self(), 0, copy, 0);
connect(copy, 0, self(), 0);

testhier_impl::testhier_impl()
: gr::hier_block2(“testhier”,
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
{
gr::blocks::copy::sptr
copy(gr::blocks::copy::make(sizeof(gr_complex)));
connect(self(), 0, copy, 0);
connect(copy, 0, self(), 0);
}

So this should be the quite simplest form of a hier block. However, the
following wierdnesses occur:

On Ubuntu:
make is successful
If I import the module in python, I get a segmentation fault. As far as
I got with gdb, the error may be somewhere in swig.
However, if I first do “from gnuradio import blocks”, the import is
successful, but the module only contains the python blocks, all c++
blocks are missing.
When I only use a block from the same OOT module in the hier block, the
import also is successful, but again the c++ blocks are missing.

On arch linux:
make fails with a linker error:
undefined reference to `gr::blocks::copy::make(unsigned long)’
However if I only use a block from the same OOT module in the hier
block, the whole thing seems to work.

What am I doing wrong? Did I forget to include something? Can it be that
hard to make a c++ hier block?

Thanks for your help

Julius

Hi,

I forgot to edit the CMakeList.txt to add the GR components that I used
(the line set(GR_REQUIRED_COMPONENTS… ).

I still find it strange, that on one PC I got a linker error (which
obviously was the Issue and led me to the solution) and the other one
builds without complaint but okay.

Regards
Julius